Cannot import Pytorch - python

While importing installed pytorch I am facing below issue
>>> import torch
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Anaconda3\lib\site-packages\torch\__init__.py", line 81, in <module>
ctypes.CDLL(dll)
File "C:\Anaconda3\lib\ctypes\__init__.py", line 364, in __init__
self._handle = _dlopen(self._name, mode)
OSError: [WinError 126] The specified module could not be found

I found a possible culprit by doing a Google search. Please read below-
It's a library load issue. More details at #8836
You probably have a broken conda right now. You can use a standalone conda from here to repair it:
standalone-conda.exe update -p C:\ProgramData\Anaconda3 conda-package-handling
You should get the latest stable version, and the problems should go away.
More details can be found here.

Related

FileNotFoundError when import scipy on anaconda python

Operating system: Windows 10 Home
Python interpreter: Anaconda with python 3.8.8
I have installed the scipy module on anaconda using "conda install
scipy==1.6.2" and it states "# All requested packages already installed.". However, when I opened python ide and import scipy, the below error appears.
The way I try to solve is through reinstalling scipy module and "conda update --all". However, these all fails. Any ways to solve this issue. Thanks in advance.
import scipy
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\tys\.conda\envs\renv\lib\site-packages\scipy\__init__.py", line 130, in <module>
from . import _distributor_init
File "C:\Users\tys\.conda\envs\renv\lib\site-packages\scipy\_distributor_init.py", line 59, in <module>
WinDLL(os.path.abspath(filename))
File "C:\Users\tys\.conda\envs\renv\lib\ctypes\__init__.py", line 373, in __init__
self._handle = _dlopen(self._name, mode)
FileNotFoundError: Could not find module 'C:\Users\tys\.conda\envs\renv\lib\site-packages\scipy\.libs\libbanded5x.3OIBJ6VWWPY6GDLEMSTXSIPCHHWASXGT.gfortran-win_amd64.dll' (or one of its dependencies). Try using the full path with constructor syntax.
You should try the solution given here (https://github.com/pytroll/satpy/issues/1835):
conda install -c defaults scipy
It worked for me.

Cannot import mxnet package in my environment

I want to install mxnet with gpu. and used pip install mxnet-cu90. However, when I am importing the package I come across this error:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\Anuj\anaconda3\envs\py36\lib\site-packages\mxnet\__init__.py", line 24, in <module>
from .context import Context, current_context, cpu, gpu, cpu_pinned
File "C:\Users\Anuj\anaconda3\envs\py36\lib\site-packages\mxnet\context.py", line 24, in <module>
from .base import classproperty, with_metaclass, _MXClassPropertyMetaClass
File "C:\Users\Anuj\anaconda3\envs\py36\lib\site-packages\mxnet\base.py", line 213, in <module>
_LIB = _load_lib()
File "C:\Users\Anuj\anaconda3\envs\py36\lib\site-packages\mxnet\base.py", line 204, in _load_lib
lib = ctypes.CDLL(lib_path[0], ctypes.RTLD_LOCAL)
File "C:\Users\Anuj\anaconda3\envs\py36\lib\ctypes\__init__.py", line 348, in __init__
self._handle = _dlopen(self._name, mode)
OSError: [WinError 126] The specified module could not be found
I tried reinstalling by downloading .whl file from this but it didn't work. Its still giving the same error.
I am using python 3.6.12.
I still don't know what was causing this problem but I solved by installing the package from conda.
First I created a brand new environment and used
conda install -c anaconda mxnet-mkl
Hopefully it works for you too.

Error when loading scipy: OSError: [WinError 126] The specified module could not be found

I have installed scipy for python3 using pip inside of a virtualenv. When I try to import scipy, I get the following error:
>>> import scipy
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\chriz\PycharmProjects\untitled1\venv\lib\site-packages\scipy\__init__.py", line 104, in <module>
from . import _distributor_init
File "C:\Users\chriz\PycharmProjects\untitled1\venv\lib\site-packages\scipy\_distributor_init.py", line 61, in <module>
WinDLL(os.path.abspath(filename))
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.7_3.7.2032.0_x64__qbz5n2kfra8p0\lib\ctypes\__init__.py", line 364, in __init__
self._handle = _dlopen(self._name, mode)
OSError: [WinError 126] The specified module could not be found
I seem to be missing some sort of dependency, but I don't know what the dependency is
When I look for the .dll that it is trying to open, it appears to be there
just faced the same error. The solution is downgrade scipy:
pip install scipy==1.4.1
I found it here:
https://github.com/pytorch/ignite/issues/1153

importing jit from numba raise an error

So I'm trying to import jit from the numba library but the import produces an OSError and says that a specific module couldn't be found.
I tried to uninstall and reinstall numba, but it didn't change anything and I have no other idea to solve the issue.
Here is the full error:
Traceback (most recent call last):
File "D:\Users\user65\Logiciels\WinPython-64bit-3.4.4.6Qt5\python-3.4.4.amd64\lib\site-packages\llvmlite\binding\ffi.py", line 42, in <module>
lib = ctypes.CDLL(os.path.join(_lib_dir, _lib_name))
File "D:\Users\user65\Logiciels\WinPython-64bit-3.4.4.6Qt5\python-3.4.4.amd64\lib\ctypes\__init__.py", line 350, in __init__
self._handle = _dlopen(self._name, mode)
OSError: [WinError 126] Le module spécifié est introuvable
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "D:/Users/user65/HypotheseDecoupageReseau/CalculInfluence.py", line 6, in <module>
from numba import jit
File "D:\Users\user65\Logiciels\WinPython-64bit-3.4.4.6Qt5\python-3.4.4.amd64\lib\site-packages\numba\__init__.py", line 11, in <module>
from . import config, errors, runtests, types
File "D:\Users\user65\Logiciels\WinPython-64bit-3.4.4.6Qt5\python-3.4.4.amd64\lib\site-packages\numba\config.py", line 11, in <module>
import llvmlite.binding as ll
File "D:\Users\user65\Logiciels\WinPython-64bit-3.4.4.6Qt5\python-3.4.4.amd64\lib\site-packages\llvmlite\binding\__init__.py", line 6, in <module>
from .dylib import *
File "D:\Users\user65\Logiciels\WinPython-64bit-3.4.4.6Qt5\python-3.4.4.amd64\lib\site-packages\llvmlite\binding\dylib.py", line 4, in <module>
from . import ffi
File "D:\Users\user65\Logiciels\WinPython-64bit-3.4.4.6Qt5\python-3.4.4.amd64\lib\site-packages\llvmlite\binding\ffi.py", line 47, in <module>
lib = ctypes.CDLL(_lib_name)
File "D:\Users\user65\Logiciels\WinPython-64bit-3.4.4.6Qt5\python-3.4.4.amd64\lib\ctypes\__init__.py", line 350, in __init__
self._handle = _dlopen(self._name, mode)
OSError: [WinError 126] Le module spécifié est introuvable
Process finished with exit code 1
Thank you for your help :)
As said in this page you are not alone. This is the problem of the version 3.4.4
You have some options:
Try upgrading and see that the problem solves.
Aside from that people saying It's due to script\python.bat and python.exe interfering.
python.bat is currently calling ptpython when it sees it, which has not the same syntax.
You may try pip uninstall ptpython and see if it helps.
You may also copy the current python.bat as winpython.bat, and keep python.bat calling only python:
#echo off
call "%~dp0env_for_icons.bat"
cd/D "%WINPYWORKDIR%"
rem backward compatibility for python.exe
"%WINPYDIR%\python.exe" %*
After following the above solutions, llvmlite error part should be solved by now. You should have Visual Studio 2015 installed for other error parts to go away.
Although you can instead install vc_redist.x86.exe alone from this link and dont install the whole VS2015. Follow here for more information.
Check if you are using a compatible version of Python.
In my case I had to remove Python and downgrade to a previous version

import jenkins in python fails on mac

I installed the jenkins package on a mac using sudo easy_install python-jenkins. The installation went fine, no errors, but when I open python and type in import jenkins I get the following error.
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "build/bdist.macosx-10.7-intel/egg/jenkins.py", line 9, in <module>
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ctypes/__init__.py", line 431, in LoadLibrary
return self._dlltype(name)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ctypes/__init__.py", line 353, in __init__
self._handle = _dlopen(self._name, mode)
OSError: dlopen(/Library/Python/2.7/site-packages/lookup3.so, 6): image not found
Googling this did not yield any helpful result.
Traceback after Editing
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "jenkins.py", line 9, in <module>
lookup3 = cdll.LoadLibrary(os.path.join(get_python_lib(), "lookup3.dynlib"))
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ctypes/__init__.py", line 431, in LoadLibrary
return self._dlltype(name)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ctypes/__init__.py", line 353, in __init__
self._handle = _dlopen(self._name, mode)
OSError: dlopen(/Library/Python/2.7/site-packages/lookup3.dynlib, 6): image not found
The module in question isn't compatible with Mac OS X dynamic library conventions.
It tries to load a lookup3.so file, but on Mac it'll be lookup3.dynlib instead. You can verify this by looking at the /Library/Python/2.7/site-packages directory. Then just edit the jenkins.py module and replace the .so extension with .dynlib.
I'd also report this to the issue tracker of the module; a simple if platform.system() == 'Darwin': switch would keep things loadable across platforms.
Update: Actually, the module stubbornly expects the lookup3.so module to be located in the site-packages directory instead of with the module itself. It is thus not easy_install compatible. It'll work when you move all the files (unaltered) out of the .egg directory straight into your /Library/Python/2.7/site-packages/ directory.
OSError: dlopen(/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/lookup3.so, 6): image not found
From the directory,
/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages,
ln -s lookup3.cpython-36m-darwin.so lookup3.so
worked for me.
You can try:
pip uninstall jenkins
pip install python-jenkins
worked for me.
I found the lookup.so jenkins.py is trying to load in:
/Users/MY-USER/Documents/Telnyx/dev/tdm-get-ips/venv/lib/python3.7/site-packages/lookup3.cpython-37m-darwin.so
so i changed
python3.7/site-packages/jenkins.py
Line:
lookup3 = cdll.LoadLibrary(os.path.join(get_python_lib(), "lookup3.so"))
for:
lookup3 = cdll.LoadLibrary(os.path.join(get_python_lib(), "lookup3.cpython-37m-darwin.so"))
And it started working properly.

Categories