h5py errors after installation - python

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

Related

Problem with 'cdqa': cannot import name 'TemporaryResourcesManager' from 'joblib._memmapping_reducer'

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,

ModuleNotFoundError: No module named 'numpy.testing.decorators'

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

ImportError: cannot import name 'ClusterDef'

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

Scikitlearn in Jupyter notebook using Anaconda

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?

Ipython notebook. %pylab load error in Windows 7

I run Windows 7, Enthought Python Distribution 7.3-2 Academic.
I open a command prompt, change to my code directory and type
U:\rsch>ipython notebook
In a new notebook, I type %pylab and receive the following error:
In [1]: %pylab
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
U:\rsch\<ipython-input-1-5c1faa999e5b> in <module>()
----> 1 get_ipython().magic(u'pylab')
D:\Python27\lib\site-packages\IPython\core\interactiveshell.pyc in magic(self, arg_s, next_input)
1983 self._magic_locals = sys._getframe(1).f_locals
1984 with self.builtin_trap:
-> 1985 result = fn(magic_args)
1986 # Ensure we're not keeping object references around:
1987 self._magic_locals = {}
D:\Python27\lib\site-packages\IPython\core\magic.pyc in magic_pylab(self, s)
3471 import_all_status = True
3472
-> 3473 self.shell.enable_pylab(s, import_all=import_all_status)
3474
3475 def magic_tb(self, s):
D:\Python27\lib\site-packages\IPython\core\interactiveshell.pyc in enable_pylab(self, gui, import_all)
2592 ns = {}
2593 try:
-> 2594 gui = pylab_activate(ns, gui, import_all, self)
2595 except KeyError:
2596 error("Backend %r not supported" % gui)
D:\Python27\lib\site-packages\IPython\core\pylabtools.pyc in pylab_activate(user_ns, gui, import_all, shell)
327 itself, and will be needed next to configure IPython's gui integration.
328 """
--> 329 gui, backend = find_gui_and_backend(gui)
330 activate_matplotlib(backend)
331 import_pylab(user_ns, import_all)
D:\Python27\lib\site-packages\IPython\core\pylabtools.pyc in find_gui_and_backend(gui)
194 """
195
--> 196 import matplotlib
197
198 if gui and gui != 'auto':
D:\Python27\lib\site-packages\matplotlib\__init__.py in <module>()
131 import sys, os, tempfile
132
--> 133 from matplotlib.rcsetup import (defaultParams,
134 validate_backend,
135 validate_toolbar,
D:\Python27\lib\site-packages\matplotlib\rcsetup.py in <module>()
17 import warnings
18 from matplotlib.fontconfig_pattern import parse_fontconfig_pattern
---> 19 from matplotlib.colors import is_color_like
20
21 #interactive_bk = ['gtk', 'gtkagg', 'gtkcairo', 'fltkagg', 'qtagg', 'qt4agg',
D:\Python27\lib\site-packages\matplotlib\colors.py in <module>()
50 """
51 import re
---> 52 import numpy as np
53 from numpy import ma
54 import matplotlib.cbook as cbook
D:\Python27\lib\site-packages\numpy\__init__.pyc in <module>()
141 return loader(*packages, **options)
142
--> 143 import add_newdocs
144 __all__ = ['add_newdocs']
145
D:\Python27\lib\site-packages\numpy\add_newdocs.py in <module>()
7 # core/fromnumeric.py, core/defmatrix.py up-to-date.
8
----> 9 from numpy.lib import add_newdoc
10
11 ###############################################################################
D:\Python27\lib\site-packages\numpy\lib\__init__.py in <module>()
11
12 import scimath as emath
---> 13 from polynomial import *
14 #import convertcode
15 from utils import *
D:\Python27\lib\site-packages\numpy\lib\polynomial.py in <module>()
15 from numpy.lib.function_base import trim_zeros, sort_complex
16 from numpy.lib.type_check import iscomplex, real, imag
---> 17 from numpy.linalg import eigvals, lstsq
18
19 class RankWarning(UserWarning):
D:\Python27\lib\site-packages\numpy\linalg\__init__.py in <module>()
46 from info import __doc__
47
---> 48 from linalg import *
49
50 from numpy.testing import Tester
D:\Python27\lib\site-packages\numpy\linalg\linalg.py in <module>()
21 isfinite, size, finfo, absolute, log, exp
22 from numpy.lib import triu
---> 23 from numpy.linalg import lapack_lite
24 from numpy.matrixlib.defmatrix import matrix_power
25 from numpy.compat import asbytes
ImportError: DLL load failed: The specified path is invalid.
Not sure what to do. Thanks.
I experienced the same problem and here is what worked for me:
I made sure I call the IPython without "pylab"
I then made sure all sessions/instances (excuse me but I'm new to this :) are closed. You can do this by ctrl-C in all Terminals and in the Notebook dashboard press "shutdown" if possible.
There are probably more elegant ways to do this but this is what worked for me.
Developers, take note that many newbies might get very frustrated when the first notebook they try to run gives them an error.
Adam
It's likely that you're missing the Scripts directory in your system path. To check, run
echo %PATH%
from the command prompt and look for D:\Python27\Scripts. If it's missing, you can add it manually from the Control Panel, or using a utility like Rapid Environment Editor.
EPD shipped with ipython 0.12. Ipython has developed a lot since then. You should update to ipython 0.13.1 by entering "enpkg ipython", as described in more detail here:
https://support.enthought.com/entries/22415022-Using-enpkg-to-update-EPD-packages
Unfortunately these error messages arent really useful. From the message you only know that 'some dll' fails to import during the import of "lapack_lite" (part of Numpy).
You can use Dependency Walker to see which specific DLL is causing the problem, opening "D:\Python27\Lib\site-packages\numpy\linalg\lapack_lite.pyd" might reveal some more information.

Categories

Resources