"ImportError: DLL load failed: The specified module could not be found" when trying to import gensim - numpy

While trying to import gensim, I run into the following error
Traceback (most recent call last):
File "c:\Users\usr\Documents\hello\test.py", line 3, in <module>
import gensim
File "C:\Users\usr\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\LocalCache\local-packages\Python37\site-packages\gensim\__init__.py", line 5, in <module>
from gensim import parsing, corpora, matutils, interfaces, models, similarities, summarization, utils # noqa:F401
File "C:\Users\usr\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\LocalCache\local-packages\Python37\site-packages\gensim\corpora\__init__.py", line 6, in <module>
from .indexedcorpus import IndexedCorpus # noqa:F401 must appear before the other classes
File "C:\Users\usr\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\LocalCache\local-packages\Python37\site-packages\gensim\corpora\indexedcorpus.py", line 15, in <module>
from gensim import interfaces, utils
File "C:\Users\usr\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\LocalCache\local-packages\Python37\site-packages\gensim\interfaces.py", line 21, in <module>
from gensim import utils, matutils
File "C:\Users\usr\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\LocalCache\local-packages\Python37\site-packages\gensim\matutils.py", line 21, in <module>
from scipy.stats import entropy
File "C:\Users\usr\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\LocalCache\local-packages\Python37\site-packages\scipy\stats\__init__.py", line 384, in <module>
from .stats import *
File "C:\Users\usr\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\LocalCache\local-packages\Python37\site-packages\scipy\stats\stats.py", line 179, in <module>
from scipy.spatial.distance import cdist
File "C:\Users\usr\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\LocalCache\local-packages\Python37\site-packages\scipy\spatial\__init__.py", line 99, in <module>
from .qhull import *
ImportError: DLL load failed: The specified module could not be found.
I have tried uninstalling numpy, scipy and gensim using pip in the command prompt and installing them again, but this does not resolve the issue.
I have also looked at the suggestions to a similar problem here, and tried installing numpy‑1.19.0+mkl‑cp37‑cp37m‑win_amd64.whl, but it resulted in a separate error Importing the numpy c-extensions failed. Thus, I have stuck to using numpy, scipy and gensim installed via pip.
Additionally, I installed scipy version 1.4.1 as the latest 1.5.0 version will give the following error as described in this link:
Error when loading scipy: OSError: [WinError 126] The specified module could not be found
Any help is greatly appreciated!
For additional information, I am using Python 3.7 and Windows 10.

I had the same problem and tried various things, but the only thing that worked for me was to install an older version of Gensim.
pip install gensim==3.7.0

Related

matplotlib import error : libwebp.so.6: cannot open shared object file: No such file or directory

I have installed matplotlib via pip3 in venv. After importing I get the error as below. Have changed the directory long path to ...PATH.
>>> import matplotlib
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "...PATH/lib/python3.11/site-packages/matplotlib/__init__.py", line 113, in <module>
from . import _api, _version, cbook, _docstring, rcsetup
File "...PATH/lib/python3.11/site-packages/matplotlib/rcsetup.py", line 27, in <module>
from matplotlib.colors import Colormap, is_color_like
File "...PATH/lib/python3.11/site-packages/matplotlib/colors.py", line 51, in <module>
from PIL import Image
File "...PATH/lib/python3.11/site-packages/PIL/Image.py", line 103, in <module>
from . import _imaging as core
ImportError: libwebp.so.6: cannot open shared object file: No such file or directory
After looking at pillow website I learnt that
Pillow >= 2.1.0 no longer supports import _imaging. Please use from
PIL.Image import core as _imaging instead.
I am using pillow 9.4.0. And the last line of matplotlib error says that it is importing _imaging, which is no more valid in pillow. Matplotlib version is 3.6.3.
For the missing shared library (libwebp), being complained in the error, I have verified that it is already installed via dev package.

Conda with Python3.9 using numpy in Python3.10

I'm trying to install statsmodels in Oracle Machine Learning in Conda enviroment.
My conda version is:
%conda
info
active environment : None
shell level : 0
user config file : /u01/.condarc
populated config files : /usr/share/conda/condarc.d/defaults.yaml
/u01/.condarc
conda version : 4.6.14
conda-build version : not installed
python version : 3.6.8.final.0
base environment : /usr (read only)
channel URLs : https://repo.anaconda.com/pkgs/main/linux-64
https://repo.anaconda.com/pkgs/main/noarch
https://repo.anaconda.com/pkgs/free/linux-64
https://repo.anaconda.com/pkgs/free/noarch
https://repo.anaconda.com/pkgs/r/linux-64
https://repo.anaconda.com/pkgs/r/noarch
package cache : /u01/.conda/pkgs
/var/cache/conda/pkgs
envs directories : /u01/.conda/envs
/usr/envs
platform : linux-64
user-agent : conda/4.6.14 requests/2.27.1 CPython/3.6.8 Linux/5.4.17-2136.314.6.3.el7uek.x86_64 oracle/7.9 glibc/2.17
UID:GID : 65000:65000
netrc file : None
offline mode : False
I created the conda enviroment with the next command:
%conda
create -n arima_enviroment python=3.9 xz sqlite libuuid statsmodels numpy
I activated the enviroment with:
%conda
activate arima_enviroment
Test the enviroment with:
%python
import sys
import platform
print("sys.version:", sys.version)
print("sys.version_info:", sys.version_info)
print("platform.python_version:", platform.python_version())
sys.version: 3.9.12 (main, Jun 1 2022, 11:38:51) [GCC 7.5.0]
sys.version_info: sys.version_info(major=3, minor=9, micro=12, releaselevel='final', serial=0)
platform.python_version: 3.9.12
Then I execute the next command for import the ARIMA model.
%python
from statsmodels.tsa.arima_model import arima
But give me the next error:
Fail to execute line 2: from statsmodels.tsa.arima_model import arima
Traceback (most recent call last):
File "/usr/local/lib/python3.10/site-packages/numpy/core/__init__.py", line 23, in <module>
from . import multiarray
File "/usr/local/lib/python3.10/site-packages/numpy/core/multiarray.py", line 10, in <module>
from . import overrides
File "/usr/local/lib/python3.10/site-packages/numpy/core/overrides.py", line 6, in <module>
from numpy.core._multiarray_umath import (
ModuleNotFoundError: No module named 'numpy.core._multiarray_umath'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/tmp/1675189382222-0/zeppelin_python.py", line 206, in <module>
exec(code, _zcUserQueryNameSpace)
File "<stdin>", line 2, in <module>
File "/u01/.conda/active_env/lib/python3.9/site-packages/statsmodels/tsa/__init__.py", line 1, in <module>
from statsmodels.tools._testing import PytestTester
File "/u01/.conda/active_env/lib/python3.9/site-packages/statsmodels/tools/__init__.py", line 1, in <module>
from .tools import add_constant, categorical
File "/u01/.conda/active_env/lib/python3.9/site-packages/statsmodels/tools/tools.py", line 4, in <module>
import numpy as np
File "/usr/local/lib/python3.10/site-packages/numpy/__init__.py", line 144, in <module>
from . import core
File "/usr/local/lib/python3.10/site-packages/numpy/core/__init__.py", line 49, in <module>
raise ImportError(msg)
ImportError:
IMPORTANT: PLEASE READ THIS FOR ADVICE ON HOW TO SOLVE THIS ISSUE!
Importing the numpy C-extensions failed. This error can happen for
many reasons, often due to issues with your setup or how NumPy was
installed.
We have compiled some common reasons and troubleshooting tips at:
https://numpy.org/devdocs/user/troubleshooting-importerror.html
Please note and check the following:
* The Python version is: Python3.9 from "/u01/.conda/active_env/bin/python3"
* The NumPy version is: "1.22.1"
and make sure that they are the versions you expect.
Please carefully study the documentation linked above for further help.
Original error was: No module named 'numpy.core._multiarray_umath'
Why conda is using Numpy in Python 3.10 folder and not the Numpy version installed in Python 3.9? How can repair it?

Keras.module needs Tf version=>2.2, but DLL's Tf load failed

This is my first question here, 'cos I am normally able to find someone else asking the same question in stackoverflow and the answers are usually very clear and detailed.
Unfortutately this time I find myself in a corner.
I am using anaconda3 (64bit) from a Win10 and I would like to import
from keras.models import Model
Unfortunately I get the following issue:
File "...\Anaconda3\lib\site-packages\keras\__init__.py", line 6, in <module>
'Keras requires TensorFlow 2.2 or higher. '
ImportError: Keras requires TensorFlow 2.2 or higher. Install TensorFlow via `pip install tensorflow`
When I have updated tensorflow to the newest version possible "2.3", I believe, but unfortunately this conflict with this other problem:
In [1]: import tensorflow as tf
Traceback (most recent call last):
File "<ipython-input-1-64156d691fe5>", line 1, in <module>
import tensorflow as tf
File "...\Anaconda3\lib\site-packages\tensorflow\__init__.py", line 41, in <module>
from tensorflow.python.tools import module_util as _module_util
File "...\Anaconda3\lib\site-packages\tensorflow\python\__init__.py", line 40, in <module>
from tensorflow.python.eager import context
File "...\Anaconda3\lib\site-packages\tensorflow\python\eager\context.py", line 35, in <module>
from tensorflow.python import pywrap_tfe
File "...\Anaconda3\lib\site-packages\tensorflow\python\pywrap_tfe.py", line 28, in <module>
from tensorflow.python import pywrap_tensorflow
File "...\Anaconda3\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 83, in <module>
raise ImportError(msg)
ImportError: Traceback (most recent call last):
File "...\Anaconda3\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 64, in <module>
from tensorflow.python._pywrap_tensorflow_internal import *
ImportError: DLL load failed: The specified module could not be found.
Failed to load the native TensorFlow runtime.
See https://www.tensorflow.org/install/errors
for some common reasons and solutions. Include the entire stack trace
above this error message when asking for help.
Do you have any suggestion?
use tf.keras.Model
Keras is implemented by default in Tensorflow 2.0

No module named 'tensorflow_datasets.image.cityscapes'

I installed TensorFlow Datasets using conda, as:
conda install -c anaconda tensorflow-datasets
I've tried importing Cityscapes:
from tensorflow_datasets.image.cityscapes import Cityscapes
but this raises the following error:
Traceback (most recent call last):
File "<input>", line 1, in <module>
File "/Applications/PyCharm.app/Contents/plugins/python/helpers/pydev/_pydev_bundle/pydev_import_hook.py", line 21, in do_import
module = self._system_import(name, *args, **kwargs)
ModuleNotFoundError: No module named 'tensorflow_datasets.image.cityscapes'
How can I fix it?
PS: I can import the following without errors:
import tensorflow_datasets as tfds
Edit:
I've already downloaded Cityscapes data, as recommended in the official guide.

numpy pandas not working in IDLE / work in Anaconda

I am running Python 3.5.1 on Windows 10 and have Anaconda and IDLE installed.
If I run any Python files, pandas and numpy seem to work in Jupyter notebooks, but not in IDLE.
I have ensured that the PATH and PYTHONPATH environment variables include access to the folders where pandas and numpy are located (Lib/site-packages).
I receive the following error in IDLE when trying to import pandas:
Traceback (most recent call last):
File "<pyshell#1>", line 1, in <module>
import pandas
File "C:\Users\me\AppData\Local\Continuum\Anaconda3\Lib\site-packages\pandas\__init__.py", line 18, in <module>
raise ImportError("Missing required dependencies {0}".format(missing_dependencies))
ImportError: Missing required dependencies ['numpy']
When I try to import numpy I get the following error:
Traceback (most recent call last):
File "<pyshell#2>", line 1, in <module>
import numpy
File "C:\Users\me\AppData\Local\Continuum\Anaconda3\Lib\site-packages\numpy\__init__.py", line 180, in <module>
from . import add_newdocs
File "C:\Users\me\AppData\Local\Continuum\Anaconda3\Lib\site-packages\numpy\add_newdocs.py", line 13, in <module>
from numpy.lib import add_newdoc
File "C:\Users\me\AppData\Local\Continuum\Anaconda3\Lib\site-packages\numpy\lib\__init__.py", line 8, in <module>
from .type_check import *
File "C:\Users\me\AppData\Local\Continuum\Anaconda3\Lib\site-packages\numpy\lib\type_check.py", line 11, in <module>
import numpy.core.numeric as _nx
File "C:\Users\me\AppData\Local\Continuum\Anaconda3\Lib\site-packages\numpy\core\__init__.py", line 14, in <module>
from . import multiarray
ImportError: cannot import name 'multiarray'
Can someone help?
try this:
I had the same problem
https://stackoverflow.com/a/40637960/6376603
maybe the above answer will help.
I had similar problem. I uninstalled anaconda from my system completely.
Steps - Delete app, delete anaconda3 folder, empty trash
Then I reinstalled older version of it and it started working perfectly. Maybe it is some kind of bug in the newer version.