FileNotFoundError when import scipy on anaconda python - 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.

Related

Python FileNotFoundError: Could not find module 'venv\DLLs\libyara.dll' (or one of its dependencies) on Windows 11

In my Python code I use yara to compile yara rules.
The documentation located at
https://yara.readthedocs.io/en/stable/yarapython.html says that I can use it by importing it like this:
import yara
However when I run the code I get
FileNotFoundError: Could not find module 'C:\Users\bruker\Pycharmprojects\projectx\venv\DLLs\libyara.dll' (or one of its dependencies). Try using the full path with constructor syntax.
I am using a venv python enviroment for this project running in Windows 11.
I have tried the following:
pip install yara
pip install --upgrade --force-reinstall yara
pip install -I yara
pip install --ignore-installed yara
However I still get that the libyara.dll file is missing:
Traceback (most recent call last):
File "C:\Users\bruker\Pycharmprojects\projectx\deploygate.py", line 14, in <module>
import yara
File "C:\Users\bruker\Pycharmprojects\projectx\venv\lib\site-packages\yara\__init__.py", line 7, in <module>
from yara.rules import compile
File "C:\Users\bruker\Pycharmprojects\projectx\venv\lib\site-packages\yara\rules.py", line 17, in <module>
from yara.libyara_wrapper import *
File "C:\Users\bruker\Pycharmprojects\projectx\venv\lib\site-packages\yara\libyara_wrapper.py", line 315, in <module>
libyaradll = cdll.LoadLibrary(library)
File "C:\Users\bruker\AppData\Local\Programs\Python\Python310\lib\ctypes\__init__.py", line 452, in LoadLibrary
return self._dlltype(name)
File "C:\Users\bruker\AppData\Local\Programs\Python\Python310\lib\ctypes\__init__.py", line 374, in __init__
self._handle = _dlopen(self._name, mode)
FileNotFoundError: Could not find module 'C:\Users\bruker\Pycharmprojects\projectx\venv\DLLs\libyara.dll' (or one of its dependencies). Try using the full path with constructor syntax.
How can I fix the yara dll file missing? I am using Python 3.10.

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.

Cannot import Pytorch

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.

Anaconda issue, DLL load failed

I installed Anaconda on my machine yesterday and installed the Anaconda Extention Pack in VSC, when I try this:
Code:
import numpy as ny
I get this error:
Traceback (most recent call last):
File "e:/Python/Testing/VSC with Anaconda/packagetest.py", line 1, in <module>
import numpy as ny
File "E:\Anaconda\lib\site-packages\numpy\__init__.py", line 140, in <module>
from . import _distributor_init
File "E:\Anaconda\lib\site-packages\numpy\_distributor_init.py", line 34, in <module>
from . import _mklinit
ImportError: DLL load failed: The specified module could not be found.
Please help me fix this.
A very common reason for this error is that the conda environment hasn't been properly activated. This can be done by either using the "Anaconda prompt" or by e.g. starting the cmd shell and then running C:\users\user_name>conda activate. This will change the prompt to (base) C:\users\user_name> and add serveral Anaconda subfolders to the PATH. Then Python should be started from there via (base) C:\users\user_name> python. Without activation numpy won't find it's DLL's.

Enthought Canopy not working on Fedora. Giving error related to Zlib not found

I installed canopy from the .sh file provided from the link of the Enthought canopy site and then ran the following command after cd into the Canopy directory.
Ashish#LoneWarrior Canopy]$ ./canopy
Subprocess output:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/home/Ashish/Canopy/appdata/canopy-2.1.3.3542.rh6-x86_64 /lib/python2.7/site-packages/pyface/gui.py", line 20, in <module>
from .toolkit import toolkit_object
File "/home/Ashish/Canopy/appdata/canopy-2.1.3.3542.rh6-x86_64/lib/python2.7/site-packages/pyface/toolkit.py", line 99, in <module>
_init_toolkit()
File "/home/Ashish/Canopy/appdata/canopy-2.1.3.3542.rh6-x86_64/lib/python2.7/site-packages/pyface/toolkit.py", line 65, in _init_toolkit
be = import_toolkit(ETSConfig.toolkit)
File "/home/Ashish/Canopy/appdata/canopy-2.1.3.3542.rh6-x86_64/lib/python2.7/site-packages/pyface/toolkit.py", line 58, in import_toolkit
__import__(be + 'init')
File "/home/Ashish/Canopy/appdata/canopy-2.1.3.3542.rh6-x86_64/lib/python2.7/site-packages/pyface/ui/qt4/init.py", line 18, in <module>
from pyface.qt import QtCore, QtGui, qt_api
File "/home/Ashish/Canopy/appdata/canopy-2.1.3.3542.rh6-x86_64/lib/python2.7/site-packages/pyface/qt/QtGui.py", line 8, in <module>
from PySide.QtGui import *
This is the main error : ZLIB_1.2.9 not found.
ImportError: /home/Ashish/Canopy/appdata/canopy-2.1.3.3542.rh6-x86_64/bin/../lib/libz.so.1: version `ZLIB_1.2.9' not found (required by /lib64/libpng16.so.16)
I have tried changing the python default to 3 but still it is not working.
I presume the problem is on an Arch-based distribution. The temporary solution in this case is to downgrade libpng to 1.6.28 (this worked in my case). If you don't have it in your cache (`/var/cache/pacman/pkg'), you can download it from https://archive.archlinux.org/packages/l/libpng/
Then, following https://wiki.archlinux.org/index.php/downgrading_packages run in the directory with the downloaded file
# pacman -U libpng-1.6.28-1-x86_64.pkg.tar.xz
(with the correct architecture, of course)
Don't forget to list libpng in /etc/pacman.conf among ignored packages to prevent upgrading. Look for the [options] section and add IgnorePkg = libpng.
Improtant. Keep in mind that downgrading packages is not harmless, therefore, this is only a temporary solution.
The problem is that the libz file in the canopy environment is not compatible with the ZLIB installed in your system.
For a quick fix: just copy the libz.so.1 file from lib directory to your canopy environment.
In my case it was
$ cp /usr/lib/libz.so.1 path-to-Canopy-install-directory/appdata/canopy-2.1.6.3665.rh6-x86_64/lib/libz.so.1

Categories