I really need some help, as I have gone through all the posts and nothing has worked. I get this error when importing gensim and not numpy (numpy is before and works fine). All I want to do is import gensim and numpy to then run my analysis.
Here is the full error message:
---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-2-3f0b98039a34> in <module>()
1 # pip install --user numpy==1.16.4
2
----> 3 import gensim
4 #import numpy
5
~/.local/lib64/python3.6/site-packages/gensim/__init__.py in <module>()
9 import logging
10
---> 11 from gensim import parsing, corpora, matutils, interfaces, models, similarities, utils # noqa:F401
12
13
~/.local/lib64/python3.6/site-packages/gensim/corpora/__init__.py in <module>()
4
5 # bring corpus classes directly into package namespace, to save some typing
----> 6 from .indexedcorpus import IndexedCorpus # noqa:F401 must appear before the other classes
7
8 from .mmcorpus import MmCorpus # noqa:F401
~/.local/lib64/python3.6/site-packages/gensim/corpora/indexedcorpus.py in <module>()
12 import numpy
13
---> 14 from gensim import interfaces, utils
15
16 logger = logging.getLogger(__name__)
~/.local/lib64/python3.6/site-packages/gensim/interfaces.py in <module>()
17 import logging
18
---> 19 from gensim import utils, matutils
20
21
~/.local/lib64/python3.6/site-packages/gensim/matutils.py in <module>()
17 import numpy as np
18 import scipy.sparse
---> 19 from scipy.stats import entropy
20 import scipy.linalg
21 from scipy.linalg.lapack import get_lapack_funcs
/cluster/apps/python/3.6.4_cpu/lib64/python3.6/site-packages/scipy/stats/__init__.py in <module>()
343 from .stats import *
344 from .distributions import *
--> 345 from .morestats import *
346 from ._binned_statistic import *
347 from .kde import gaussian_kde
/cluster/apps/python/3.6.4_cpu/lib64/python3.6/site-packages/scipy/stats/morestats.py in <module>()
10 sqrt, ceil, floor, array, compress,
11 pi, exp, ravel, count_nonzero, sin, cos, arctan2, hypot)
---> 12 from numpy.testing.decorators import setastest
13
14 from scipy._lib.six import string_types
ModuleNotFoundError: No module named 'numpy.testing.decorators'
What I have tried:
I have tried using the latest version of numpy, and also forcing it to the version 1.16.4 "pip install --user numpy==1.16.4". I have also tried uninstalling and reinstalling both gensim and numpy, but its not working. I am using Python 3.6 and on a cluster. I don't really understand why numpy has no problem being imported, but that this is a problem of gensim.
Can anyone kindly help me out with this?
Thanks a lot!
Best,
Sandra
Related
I am trying to use the cdqa library (https://github.com/cdqa-suite/cdQA). I cloned the GitHub repository using "git clone" and changed the specified versions of pandas and pytorch in the "requirements.txt" file for my versions (because I had problems installing the specific versions requested for these two libraries and, according to the "issues" in that github repository, several people managed to install cdqa by changing the versions in "requirements.txt"). Then, I used:
cd cdQA
pip install -e .
Now, I'm running the example that is in that library's GitHub repository:
import pandas as pd
from ast import literal_eval
from cdqa.utils.filters import filter_paragraphs
from cdqa.utils.download import download_model, download_bnpp_data
from cdqa.pipeline.cdqa_sklearn import QAPipeline
#from cdqa.pipeline import QAPipeline
# Download data and models
download_bnpp_data(dir='./data')
download_model(model='bert-squad_1.1', dir='./Models')
# Loading data and filtering / preprocessing the documents
df = pd.read_csv('data/bnpp_newsroom-v1.1.csv', converters={'paragraphs': literal_eval})
df = filter_paragraphs(df)
# Loading QAPipeline with CPU version of BERT Reader pretrained on SQuAD 1.1
cdqa_pipeline = QAPipeline(reader='Models/bert_qa.joblib')
but it returns the following error:
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-29-596fa5ffc73b> in <module>
4 from cdqa.utils.filters import filter_paragraphs
5 from cdqa.utils.download import download_model, download_bnpp_data
----> 6 from cdqa.pipeline.cdqa_sklearn import QAPipeline
7 #from cdqa.pipeline import QAPipeline
8
~/Documents/GIT/QA/cdQA/cdqa/pipeline/__init__.py in <module>
----> 1 from .cdqa_sklearn import QAPipeline
2
3 __all__ = ["QAPipeline"]
~/Documentos/Morning_Star_Consulting/GIT/QA/cdQA/cdqa/pipeline/cdqa_sklearn.py in <module>
----> 1 import joblib
2 import warnings
3
4 import pandas as pd
5 import numpy as np
~/anaconda3/lib/python3.8/site-packages/joblib/__init__.py in <module>
118 from .numpy_pickle import load
119 from .compressor import register_compressor
--> 120 from .parallel import Parallel
121 from .parallel import delayed
122 from .parallel import cpu_count
~/anaconda3/lib/python3.8/site-packages/joblib/parallel.py in <module>
24 from .logger import Logger, short_format_time
25 from .disk import memstr_to_bytes
---> 26 from ._parallel_backends import (FallbackToBackend, MultiprocessingBackend,
27 ThreadingBackend, SequentialBackend,
28 LokyBackend)
~/anaconda3/lib/python3.8/site-packages/joblib/_parallel_backends.py in <module>
17 from .pool import MemmappingPool
18 from multiprocessing.pool import ThreadPool
---> 19 from .executor import get_memmapping_executor
20
21 # Compat between concurrent.futures and multiprocessing TimeoutError
~/anaconda3/lib/python3.8/site-packages/joblib/executor.py in <module>
10
11 from ._memmapping_reducer import get_memmapping_reducers
---> 12 from ._memmapping_reducer import TemporaryResourcesManager
13 from .externals.loky.reusable_executor import _ReusablePoolExecutor
14
ImportError: cannot import name 'TemporaryResourcesManager' from 'joblib._memmapping_reducer' (/home/user/anaconda3/lib/python3.8/site-packages/joblib/_memmapping_reducer.py)
How could I fix that error, which I think is related to joblib? Thanks a lot.
make sure your python version is >=3.8.0
modify this file
python3.8/site-packages/joblib/externals/cloudpickle/cloudpickle.py
line 135
change to
co.co_kwonlyargcount,
0,
co.co_nlocals,
About a week ago I was able to import tensor flow but now I seem to have a problem running the same code. When I run either of these I am not able to get it to work at this point (what surprises me the most is at least part of it worked last week, now it does not seem to work), I get ImportError: cannot import name 'ClusterDef' which I am not finding anything online on:
import tensorflow
import keras
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-2-a649b509054f> in <module>()
----> 1 import tensorflow
/anaconda3/lib/python3.6/site-packages/tensorflow/__init__.py in <module>()
39 import sys as _sys
40
---> 41 from tensorflow.python.tools import module_util as _module_util
42 from tensorflow.python.util.lazy_loader import LazyLoader as _LazyLoader
43
/anaconda3/lib/python3.6/site-packages/tensorflow/python/__init__.py in <module>()
75
76 # Bring in subpackages.
---> 77 from tensorflow.python.estimator import estimator_lib as estimator
78 from tensorflow.python.layers import layers
79 from tensorflow.python.ops import image_ops as image
/anaconda3/lib/python3.6/site-packages/tensorflow/python/estimator/estimator_lib.py in <module>()
20
21 # pylint: disable=unused-import,line-too-long
---> 22 from tensorflow.python.estimator.estimator import Estimator
23 from tensorflow.python.estimator.export import export_lib as export
24 from tensorflow.python.estimator.inputs import inputs
/anaconda3/lib/python3.6/site-packages/tensorflow/python/estimator/estimator.py in <module>()
48 from tensorflow.python.training import monitored_session
49 from tensorflow.python.training import saver
---> 50 from tensorflow.python.training import training
51 from tensorflow.python.util import compat
52
/anaconda3/lib/python3.6/site-packages/tensorflow/python/training/training.py in <module>()
180
181 # Distributed computing support.
--> 182 from tensorflow.core.protobuf.tensorflow_server_pb2 import ClusterDef
183 from tensorflow.core.protobuf.tensorflow_server_pb2 import JobDef
184 from tensorflow.core.protobuf.tensorflow_server_pb2 import ServerDef
ImportError: cannot import name 'ClusterDef'
There is usually two reasons for ImportError
it's circular import attempt
the target object does not exist
in your case i would check if this file really contains ClusterDef class
/anaconda3/lib/python3.6/site-packages/tensorflow/core/protobuf/tensorflow_server_pb2.py
this is dynamically generated protobuf files (by grpc), which could somehow got deleted
in case this file does not contain needed class the best option is probably reinstall tensorflow/anaconda
Import command:
"from rasa_core.agent import Agent"
gives me the following error
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-43-bdf78c35345b> in <module>()
5 from rasa_core import training
6 from rasa_core.actions import Action
----> 7 from rasa_core.agent import Agent
8 from rasa_core.domain import Domain
9 from rasa_core.policies.keras_policy import KerasPolicy
C:\ProgramData\Miniconda3\lib\site-packages\rasa_core\agent.py in <module>()
15 import rasa_core
16 from rasa_core import training, constants
---> 17 from rasa_core.channels import UserMessage, OutputChannel, InputChannel
18 from rasa_core.constants import DEFAULT_REQUEST_TIMEOUT
19 from rasa_core.dispatcher import Dispatcher
C:\ProgramData\Miniconda3\lib\site-packages\rasa_core\channels\__init__.py in <module>()
15 from rasa_core.channels.botframework import BotFrameworkInput # nopep8
16 from rasa_core.channels.callback import CallbackInput # nopep8
---> 17 from rasa_core.channels.console import CmdlineInput # nopep8
18 from rasa_core.channels.facebook import FacebookInput # nopep8
19 from rasa_core.channels.mattermost import MattermostInput # nopep8
C:\ProgramData\Miniconda3\lib\site-packages\rasa_core\channels\console.py in <module>()
1 # this builtin is needed so we can overwrite in test
----> 2 import questionary
3
4 import json
5 import requests
C:\ProgramData\Miniconda3\lib\site-packages\questionary\__init__.py in <module>()
3
4 import questionary.version
----> 5 from questionary.form import Form
6 from questionary.form import form
7 from questionary.prompt import prompt
C:\ProgramData\Miniconda3\lib\site-packages\questionary\form.py in <module>()
1 from collections import namedtuple
2
----> 3 from questionary.constants import DEFAULT_KBI_MESSAGE
4 from questionary.question import Question
5
C:\ProgramData\Miniconda3\lib\site-packages\questionary\constants.py in <module>()
38 ('selected', ''), # style for a selected item of a checkbox
39 ('separator', ''), # separator in lists
---> 40 ('instruction', '') # user instructions for select, rawselect, checkbox
41 ])
TypeError: object() takes no parameters
This error also reappears in some other Rasa imports.
Following are my versions:
Python - 3.6.6
rasa_core - 0.13.3
rasa_nlu- 0.14.4
There is a requirement list that is available online but the answer where it was posted resulted in error still not resolving.
Any help is appreciated.
I had faced a similar issue.
Installing the following libraries with the version should resolve the error:
python==3.6.7
rasa_core==0.9.6
rasa_nlu==0.14.4
spacy==2.0.18
pandas==0.22.0
sklearn_crfsuite== 0.3.6
Cheers!
Edit: Make sure you create a new python environment while installing the above to avoid interdependency issues.
This is not a duplicate because the linked question does not address how to either locate the required dlls or fix the installation.
I get the following when I try import sklearn v.0.20. I'm using anaconda and both numpy and scipy are up to date.
ImportError Traceback (most recent call last)
<ipython-input-1-8fd979e02004> in <module>()
----> 1 import sklearn
C:\Users\James2SxyBoogaloo\Anaconda3\lib\site-packages\sklearn\__init__.py in <module>()
62 else:
63 from . import __check_build
---> 64 from .base import clone
65 from .utils._show_versions import show_versions
66
C:\Users\James2SxyBoogaloo\Anaconda3\lib\site-packages\sklearn\base.py in <module>()
11 from scipy import sparse
12 from .externals import six
---> 13 from .utils.fixes import signature
14 from . import __version__
15
C:\Users\James2SxyBoogaloo\Anaconda3\lib\site-packages\sklearn\utils\__init__.py in <module>()
11
12 from .murmurhash import murmurhash3_32
---> 13 from .validation import (as_float_array,
14 assert_all_finite,
15 check_random_state, column_or_1d, check_array,
C:\Users\James2SxyBoogaloo\Anaconda3\lib\site-packages\sklearn\utils\validation.py in <module>()
20
21 from ..externals import six
---> 22 from ..utils.fixes import signature
23 from .. import get_config as _get_config
24 from ..exceptions import NonBLASDotWarning
C:\Users\James2SxyBoogaloo\Anaconda3\lib\site-packages\sklearn\utils\fixes.py in <module>()
81 return stats.boxcox(x, lmbda)
82 else:
---> 83 from scipy.special import boxcox # noqa
84
85
C:\Users\James2SxyBoogaloo\Anaconda3\lib\site-packages\scipy\special\__init__.py in <module>()
638 from .sf_error import SpecialFunctionWarning, SpecialFunctionError
639
--> 640 from ._ufuncs import *
641
642 from .basic import *
ImportError: DLL load failed: The specified module could not be found.
EDIT:
I found this thread : https://github.com/numpy/numpy/issues/10965
That mentions a problem related to this.
So it seems the guy there solved his problem by removing both numpy and scipy and reinstalling them. There is a chance your version of scipy for some reason is linked against a MLK version of numpy and that's the reason things don't work.
END OF EDIT
I checked around for your problem and it seems that this is related to the version of numpy you have.
To fix the problem you should install numpy-MLK which is a version on numpy linked against Intel's Math Kernel Library.
You can find it here:
https://pypi.org/project/numpy-mkl/
Just remember to first remove the already existing numpy package.
You can find more info here:
ImportError when importing certain modules from SciPY
and here:
Difference between Numpy and Numpy-MKL?
I'm trying to install h5py on Mac OSX and use it's group and dataset features, but I'm having an issue. On its installation webpage it says the easiest way for beginners to use it on Mac is to install Anaconda, so that's what I did since I would still consider myself an inexperienced programmer. Anyway, after installing Anaconda and typing the following script into iPython Notebook, I get an "image not found error."
import h5py
import numpy as np
f = h5py.File("mytestfile.hdf5" , "w")
Here is the full error (its pretty long):
ImportError Traceback (most recent call last)
<ipython-input-1-65d72c32bd56> in <module>()
----> 1 import h5py
2 import numpy as np
3
4 f = h5py.File("mytestfile.hdf5", "w")
/Users/wlentzii/anaconda/lib/python2.7/site-packages/h5py/__init__.py in <module>()
21 _errors.silence_errors()
22
---> 23 from . import _conv
24 _conv.register_converters()
25
h5py/h5t.pxd in init h5py._conv (-------src-dir--------/h5py/_conv.c:6961)()
h5py/numpy.pxd in init h5py.h5t (-------src-dir--------/h5py/h5t.c:19623)()
/Users/wlentzii/Library/Enthought/Canopy_64bit/User/lib/python2.7/site- packages/numpy/__init__.pyc in <module>()
166 return loader(*packages, **options)
167
--> 168 from . import add_newdocs
169 __all__ = ['add_newdocs', 'ModuleDeprecationWarning']
170
/Users/wlentzii/Library/Enthought/Canopy_64bit/User/lib/python2.7/site- packages/numpy/add_newdocs.py in <module>()
11 from __future__ import division, absolute_import, print_function
12
---> 13 from numpy.lib import add_newdoc
14
15 ###############################################################################
/Users/wlentzii/Library/Enthought/Canopy_64bit/User/lib/python2.7/site- packages/numpy/lib/__init__.py in <module>()
16
17 from . import scimath as emath
---> 18 from .polynomial import *
19 #import convertcode
20 from .utils import *
/Users/wlentzii/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/numpy/lib/polynomial.py in <module>()
17 from numpy.lib.function_base import trim_zeros, sort_complex
18 from numpy.lib.type_check import iscomplex, real, imag
---> 19 from numpy.linalg import eigvals, lstsq, inv
20
21 class RankWarning(UserWarning):
/Users/wlentzii/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/numpy/linalg/__init__.py in <module>()
48 from .info import __doc__
49
---> 50 from .linalg import *
51
52 from numpy.testing import Tester
/Users/wlentzii/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/numpy/linalg/linalg.py in <module>()
27 )
28 from numpy.lib import triu, asfarray
---> 29 from numpy.linalg import lapack_lite, _umath_linalg
30 from numpy.matrixlib.defmatrix import matrix_power
31 from numpy.compat import asbytes
ImportError: dlopen(/Users/wlentzii/Library/Enthought/Canopy_64bit/User/lib /python2.7/site-packages/numpy/linalg/lapack_lite.so, 2): Library not loaded: #rpath/lib/libmkl_intel_lp64.dylib
Referenced from: /Users/wlentzii/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/numpy/linalg/lapack_lite.so
Reason: image not found
Your traceback shows that you are using Canopy's Python, not Anaconda's. Either (1) make sure Anaconda appears in your system path before Canopy or (2) use Canopy's package manager to install h5py. Since you have Canopy installed already, and that's what appears first in your path already, that might be the easiest choice for you. You can either use the graphical Package Manager (reachable from the Welcome screen) or install h5py from the command-line
enpkg h5py