I cannot import caffe into (anaconda-) python.
I'm following a notebook example on "logistic regression on non-image HDF5 data". When I execute the line
import caffe
I get the following error:
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-17-3524921938b5> in <module>()
8 sys.path.insert(0, caffe_root + 'python')
9
---> 10 import caffe
11
/home/myName/libs/caffe/caffe-master-anaconda-python/python/caffe/__init__.py in <module>()
----> 1 from .pycaffe import Net, SGDSolver
2 from ._caffe import set_mode_cpu, set_mode_gpu, set_device, Layer, get_solver
3 from .proto.caffe_pb2 import TRAIN, TEST
4 from .classifier import Classifier
5 from .detector import Detector
/home/myName/libs/caffe/caffe-master-anaconda-python/python/caffe/pycaffe.py in <module>()
11 import numpy as np
12
---> 13 from ._caffe import Net, SGDSolver
14 import caffe.io
15
ImportError: libjpeg.so.62: cannot open shared object file: No such file or directory
The library libjpeg.so.62 is definetly installed under /usr/lib/i386-linux-gnu/libjpeg.so.62. I don't know what is going wrong here or how to tell anacondapython where to look for libjpeg.so.62.
I already tried out sudo apt-get install libjpeg62:i386 but apt-get says "libjpeg62:i386 is already the newest version. libjpeg62:i386 set to manually installed."
I compiled caffe while modifying "Makefile.config" such that it was pointing it to the ananconda python path. I also exported the PYTHONPATH and PATH of my anaconda directory:
export PATH="/home/myName/libs/anaconda/bin:$PATH"
export PYTHONPATH="/home/myName/libs/caffe/caffe-master-anaconda-python/python:$PYTHONPATH"
Ok I finally found the solution:
I had to sudo apt-get install libjpeg62
After that a new error occurred while trying to import caffe, namely
ImportError: /home/myName/libs/anaconda/bin/../lib/libm.so.6: version `GLIBC_2.15' not found (required by /usr/lib/x86_64-linux-gnu/libx264.so.142)
That could be solved by removing some buggy anaconda libraries thus resorting to the system libraries,quote shelhamer:
"Some versions of Anaconda seem to come with a bad libm. rm ~/anaconda/lib/libm.* takes care of this by reverting to the system libm."
see github bvlc
Related
(Similar questions I have found on StackOverflow are answered for a different OS)
I'm facing some issues using numpy in my new macbook (os Big Sur).
I've used pip3 to install numpy etc but it only seems to work inside VSCode.
pip3 install numpy
Inside VSCode everything runs smoothly, even the ipynbs.
But whenever I try to run numpy using either a terminal or Jupyter notebook
import numpy as np
I'm getting the following error:
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
~/Library/Python/3.8/lib/python/site-packages/numpy/core/__init__.py in <module>
21 try:
---> 22 from . import multiarray
23 except ImportError as exc:
~/Library/Python/3.8/lib/python/site-packages/numpy/core/multiarray.py in <module>
11
---> 12 from . import overrides
13 from . import _multiarray_umath
~/Library/Python/3.8/lib/python/site-packages/numpy/core/overrides.py in <module>
6
----> 7 from numpy.core._multiarray_umath import (
8 add_docstring, implement_array_function, _get_implementing_args)
ImportError: dlopen(/Users/ahsantarique/Library/Python/3.8/lib/python/site-packages/numpy/core/_multiarray_umath.cpython-38-darwin.so, 2): no suitable image found. Did find:
/Users/ahsantarique/Library/Python/3.8/lib/python/site-packages/numpy/core/_multiarray_umath.cpython-38-darwin.so: mach-o, but wrong architecture
/Users/ahsantarique/Library/Python/3.8/lib/python/site-packages/numpy/core/_multiarray_umath.cpython-38-darwin.so: mach-o, but wrong architecture
During handling of the above exception, another exception occurred:
ImportError Traceback (most recent call last)
<ipython-input-2-0aa0b027fcb6> in <module>
----> 1 import numpy as np
~/Library/Python/3.8/lib/python/site-packages/numpy/__init__.py in <module>
138 from . import _distributor_init
139
--> 140 from . import core
141 from .core import *
142 from . import compat
~/Library/Python/3.8/lib/python/site-packages/numpy/core/__init__.py in <module>
46 """ % (sys.version_info[0], sys.version_info[1], sys.executable,
47 __version__, exc)
---> 48 raise ImportError(msg)
49 finally:
50 for envkey in env_added:
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.8 from "/Library/Developer/CommandLineTools/usr/bin/python3"
* The NumPy version is: "1.19.4"
and make sure that they are the versions you expect.
Please carefully study the documentation linked above for further help.
Original error was: dlopen(/Users/**/Library/Python/3.8/lib/python/site-packages/numpy/core/_multiarray_umath.cpython-38-darwin.so, 2): no suitable image found. Did find:
/Users/**/Library/Python/3.8/lib/python/site-packages/numpy/core/_multiarray_umath.cpython-38-darwin.so: mach-o, but wrong architecture
/Users/**/Library/Python/3.8/lib/python/site-packages/numpy/core/_multiarray_umath.cpython-38-darwin.so: mach-o, but wrong architecture
I've found a workaround.
Seems like the problem was I didn't have the python bin in the path variable
So I removed numpy completely first
pip3 uninstall numpy
added the path
PATH=$PATH:the/python/bin/directory/that/was/showing
Then reinstalled numpy
pip3 install numpy
I'm not sure if that's the way to go but it solved this ImportError for now.
VSCode lets you choose which interpreter you are using,This is most probabaly your probelm because VSCode is using a differnt interpreter,with different pacakages, than your system.
The fisrt step is:
First you need to know what version of python your system is using, to know which version of python your system uses type python3 --version in the terminal
The second step is:
Then you need to make VSCode use the same version of python as your system ,to do this type ctrl+shift+p to open the command palette in VSCode then in the command palette type or choose “Python: Select Interpreter then select the same version that your system is using.
The last step is:
Since the system install of python doesnt have numpy installed you need to install it by typing pip3 install numpy
I have a package called boo which I install on google colab from a github repository. The installation process looks fine and results in success message Successfully installed boo-0.1. However import boo fails on first internal import.
I replicated the same installation steps in a local virtual environment and package worked, but not on collab.
Here are my steps and error trace:
!rm -rf sandbox
!git clone https://github.com/ru-corporate/sandbox.git
!pip install -r sandbox/requirements.txt
!pip install sandbox/.
Alternatively, I tried
!pip install git+https://github.com/ru-corporate/sandbox.git#master
The error trace is:
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-7-fc0b1d036b35> in <module>()
----> 1 import boo
/usr/local/lib/python3.6/dist-packages/boo/__init__.py in <module>()
----> 1 from boo.boo import download, build, read_dataframe, files
2 from boo.views.whatis import whatis
/usr/local/lib/python3.6/dist-packages/boo/boo.py in <module>()
3 from tqdm import tqdm
4
----> 5 from boo.file.download import curl
Basically, from root __init__.py the import goes to root boo.py and stumbles upon finding boo/file/download.py.
How do I make this package work on collab?
I could fix the subpackage behavior by editing setup.py as suggested here:
# ...
packages=setuptools.find_packages()
# ...
Somehow Colab is more restrictive on this parameter than local installation.
hy I followed the installation instructions here
and installed with
pip install --upgrade azureml-sdk[notebooks,automl] azureml-dataprep --ignore-installed PyYAML
It seem to work but a simple
import azureml.core
azureml.core.VERSION
Throws me a numpy error
> AttributeError Traceback (most recent call
> last) <ipython-input-3-08b704cd5542> in <module>
> ----> 1 import azureml.core
> 2 azureml.core.VERSION
c:\users\werth\appdata\local\continuum\anaconda3\envs\azuresdk\lib\site-packages\azureml\core\__init__.py in <module>
4
5 """Setup file for core package."""
----> 6 from azureml.core.workspace import Workspace
7 from azureml.core.experiment import Experiment
8 from azureml.core.runconfig import RunConfiguration
... I did not include the total traceback as it is apparently a Azure import problem.
AttributeError: type object 'numpy.ndarray' has no attribute '__array_function__'
It seems that the workspace has a problem. But I cannot think why. The Notebook is in a subfolder of the working directory. Numpy is installed.
If you would have an idea I would be thankfull.
Hi greatest Floridaman,
the answer is simple. During the installation of the azureml-train-automl 1.0.8 package, the numpy package needs to be maximum at version 1.15.0
So just downgrade numpy to that version
conda install numpy=1.15.0
So I am trying to get hmmlearn working in Jupyter, and I have come across an error while installing Hmmlearn using pip. I have tried this solution, but it didn't work.
It seems to me that pip does install the _hmmc file, but it does so incorrect. instead it has the name
_hmmc.cp35-win_amd64
and the file extesion is .PYD, instead of .c
When I run the code to import it, I get this error :
ImportError Traceback (most recent call last)
<ipython-input-1-dee84c3d5ff9> in <module>()
7 import os
8 from pyAudioAnalysis import audioBasicIO as aB
----> 9 from pyAudioAnalysis import audioAnalysis as aA
C:\Users\gover_000\Documents\GitHub\Emotion-Recognition-Prototype\pyAudioAnalysis\audioAnalysis.py in <module>()
15 import audioFeatureExtraction as aF
16 import audioTrainTest as aT
---> 17 import audioSegmentation as aS
18 import audioVisualization as aV
19 import audioBasicIO
C:\Users\gover_000\Documents\GitHub\Emotion-Recognition-Prototype\pyAudioAnalysis\audioSegmentation.py in <module>()
16 import sklearn
17 import sklearn.cluster
---> 18 import hmmlearn.hmm
19 import cPickle
20 import glob
C:\Users\gover_000\Anaconda3\envs\python2\lib\site-packages\hmmlearn\hmm.py in <module>()
19 from sklearn.utils import check_random_state
20
---> 21 from .base import _BaseHMM
22 from .utils import iter_from_X_lengths, normalize
23
C:\Users\gover_000\Anaconda3\envs\python2\lib\site-packages\hmmlearn\base.py in <module>()
11 from sklearn.utils.validation import check_is_fitted
12
---> 13 from . import _hmmc
14 from .utils import normalize, log_normalize, iter_from_X_lengths
15
ImportError: cannot import name _hmmc
I don't know why pip just doesn't install it correctly, even when I tried to use --no-cache-dir
Edit: So i figured out what the problem was. my active python enviroment was python 3.5, as i was manually transferring the installed files to my enviroment, it failed because i had the wrong version.
I had to change my active python enviroment: using activate <my_enviroment name>
after that i could just use pip to install it again and it worked this time.
Looking at your error message I guess that you have downloaded the hmmlearn package from GIT. Have you tried using a wheel (*.whl) file instead? You can download one from here. Check out which version fits your python installation.
Then use:
pip install <the_wheel_that_corresponds_to_your_python_version>.whl
Hope it helps.
So i figured out what the problem was. my active python enviroment was python 3.5, as i was manually transferring the installed files to my enviroment, it failed because i had the wrong version. I had to change my active python enviroment: using activate <my_enviroment_name> after that i could just use pip to install it again and it worked this time.
not sure if it could be helpful to anyone but I installed hmmlearn as follows in my Jupyter Lab:
import sys
!{sys.executable} -m pip install hmmlearn
I am trying to use the sklearn.qda package in python. I have installed it successfully but when Itry to import it I get the error message below. Can anybody tell me what should I do to fix this?
In [3]: from sklearn.qda import QDA
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-3-7d7abf937d66> in <module>()
----> 1 from sklearn.qda import QDA
/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/sklearn/qda.py in <module>()
12
13 from .base import BaseEstimator, ClassifierMixin
---> 14 from .utils.fixes import unique
15 from .utils import check_arrays, array2d
16
/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/sklearn/utils/__init__.py in <module>()
7 import warnings
8
----> 9 from .murmurhash import murmurhash3_32
10 from .validation import (as_float_array, check_arrays, safe_asarray,
11 assert_all_finite, array2d, atleast2d_or_csc,
ImportError: cannot import name murmurhash3_32
I had the same problem, I run:
sudo pip install -U scikit-learn
and now everything is working fine
I started a new shell and this problem went away
I faced the similar situation of getting mumurhash error while installing sklearn.preprocessing library.
I upgraded numpy version from 1.13 to 1.15
using
pip install --upgrade numpy
After this, I was able to import the sklearn library.
I fixed this by upgrading murmurhash to 1.0.5.
I faced a similar problem, so there are mainly two solutions
Either run it in administrator mode and install all the libraries and run in admin mode. Something that I would not recommend
Use virtualenv to install the libraries again and run your command in the virtualenv. This worked for me.
Hope this helps