I'm trying to install python-igraph package. Installation works without any warning nor error, but then, when I try to import the module, I get an error:
In [1]: import igraph
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-1-8e950eb5d8d8> in <module>()
----> 1 import igraph
/usr/local/lib/python2.7/site-packages/igraph/__init__.py in <module>()
32 # pylint: disable-msg=W0401
33 # W0401: wildcard import
---> 34 from igraph._igraph import *
35 from igraph._igraph import __version__, __build_date__
36 from igraph.clustering import *
ImportError: dlopen(/usr/local/lib/python2.7/site-packages/igraph/_igraph.so, 2): Library not loaded: /usr/local/opt/gmp/lib/libgmp.10.dylib
Referenced from: /usr/local/opt/glpk/lib/libglpk.36.dylib
Reason: Incompatible library version: libglpk.36.dylib requires version 14.0.0 or later, but libgmp.10.dylib provides version 13.0.0
I can't manage to solve this problem. I saw this post and tried their solutions but it did not work (the problem there was that glpk was not installed, whereas for me it is installed).
To install it I did the following:
brew tap homebrew/science
brew install igraph
sudo pip install python-igraph
And I checked that gmp and glpk were installed with brew install igraph
Does anybody have an idea of how I could manage to install it?
I'm working on Mac os x el capitan, with python2.7
Thanks for your help
Edit from Tamás answer:
I checked, and gmp and glpk do come from homebrew. In fact, /usr/local/opt/gmp is a symlink to <path_to_>Cellar/gmp/6.0.0aand /usr/local/opt/glpk to <path_to_>Cellar/glpk/4.57.
I tried anyway to uninstall igraph (brew uninstall igraph), move somewhere else the files in /usr/local/opt for gmp and glpk, and reinstall igraph. But I get exactely the same error while importing the python module...
It seems like GMP and GLPK are not coming from Homebrew and they are not compatible with each other. You have to fix the installation of GMP and GLPK. Alternatively, you can uninstall igraph, then temporarily move GMP's and GLPK's directories from /usr/local/opt to somewhere else, then install igraph again. igraph will then "think" that GLPK and GMP are not available on your machine and compiles itself without GLPK and GMP support (and disable some features that require GLPK and GMP).
Solved:
Thanks to your comments, I realized that, in fact, Homebrew did not have the last version of gmp.
So, I downloaded the last version from gmp website, and:
uninstalled igraph
installed gmp from the downloaded version
reinstalled igraph
And now it works, I can import the python package!
Related
I am trying to set up ortools on my Mac.
I installed via pip install ortools. I can verify that the package installed successfully.
conda list | grep ortools
WARNING: The conda.compat module is deprecated and will be removed in a future release.
ortools 7.1.6720 pypi_0 pypi
When I try to use the library, it looks like there are missing functions. I followed along with the example here:
https://developers.google.com/optimization/introduction/python
This returns an error:
from __future__ import print_function
from ortools.linear_solver import pywraplp
Traceback (most recent call last):
File "simple_ortools_example.py", line 2, in <module>
from ortools.linear_solver import pywraplp
ImportError: No module named ortools.linear_solver
I can import the module otherwise and look at the functions interactively:
>>> ortools.__
ortools.__cached__ ortools.__gt__( ortools.__path__
ortools.__class__( ortools.__hash__( ortools.__reduce__(
ortools.__delattr__( ortools.__init__( ortools.__reduce_ex__(
ortools.__dict__ ortools.__init_subclass__( ortools.__repr__(
ortools.__dir__( ortools.__le__( ortools.__setattr__(
ortools.__doc__ ortools.__loader__ ortools.__sizeof__(
ortools.__eq__( ortools.__lt__( ortools.__spec__
ortools.__file__ ortools.__name__ ortools.__str__(
ortools.__format__( ortools.__ne__( ortools.__subclasshook__(
ortools.__ge__( ortools.__new__( ortools.__version__
ortools.__getattribute__( ortools.__package__
I just used tab complete here to see what was available. Sure enough there is no linear_solver attached to the ortools module.
I'm a bit at a loss as to what to try next. Any advice would be apreciated.
I downgraded to an earlier version which solves the problem.
pip install ortools==6.7.4973
I faced the same issue today on Windows. Figured out that it is usually caused due to missing Microsoft Visual Studio 20** redistributables c++ (see here).
This is how I solved it (Python 3.7.6, ortools Version: 7.5.*).
Got the latest Microsoft Visual Studio 20** redistributables c++ from https://support.microsoft.com/en-my/help/2977003/the-latest-supported-visual-c
downloads
Installed it and Restarted the computer.
Uninstall the ortools 'python -m pip uninstall ortools'
Install back the ortools 'python -m pip install --user ortools'
Validated installation with python -c "from ortools.linear_solver import pywraplp"
I have installed Python 3.6.4. When I import cv2, it throws this error:
DLL load failed: The specified module could not be found.
I have OpenCV version 2.4.13.
What should i do?
It's possible that you have Python 2 and 3 installed and Python 3 doesn't know about your opencv installation. Try this:
pip3 install opencv-python
That will install opencv for Python 3 and hopefully that fixes your problem.
Try doing this:
Go to command prompt and "cd" the directory of python.
Enter this if you are running Python 3.x.x
pip3 install opencv-python
OR
2.If on Python 2.x.x
pip2 install opencv-python
DO NOT USE:
pip install opencv
That was my mistake and had to dig a lot to find a solution.
In my situation,
ImportError Traceback (most recent call last)
in ()
10 import os.path
11 from keras.models import load_model
---> 12 import cv2
13 from utils.utils import get_yolo_boxes, makedirs
14 from PIL import Image
ImportError: DLL load failed: The specified module could not be found.
Face this ImportError in the pass week, and I solved with enter below scripts in the Anaconda Prompt.
conda install -c menpo opencv
And here is my environment:
Python 3.6.5 Anaconda
Keras 2.2.2
tensorflow 1.9.0
For more details, here is the log I tried to solved this ImportError:
micky619/holiday-similarity#3
This can happen if you are using windows 10 N distribution, the N distributions does not come pre installed with windows media feature pack, which is required after OpenCV version 3.4 and onwards.
The preferred solution is to install the feature pack at : https://www.microsoft.com/en-us/software-download/mediafeaturepack
Be careful to choose the version that works with your current version of windows.
If that is not an option, fall back to an earlier version of OpenCV that does not have dll dependencies, you can do that by:pip install opencv-python=3.3.0.9
If the problem still persists try using Dependency walker to find out where specifically your problems stem from and then try fixing them individually.
Since windows rolled out it's N version this problem has been seen at many places, and has many impacts across the windows environment, the fastest way to identify if you have this problem is open youtube in Edge browser, if it says HTML5 media plugin not found, this is the problem.
I am trying to run the following simple code
import scipy
scipy.test()
But I am getting the following error
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Python27\lib\site-packages\spyderlib\widgets\externalshell\sitecustomize.py", line 586, in runfile
execfile(filename, namespace)
File "C:/Users/Mustafa/Documents/My Python Code/SpectralGraphAnalysis/main.py", line 8, in <module>
import scipy
File "C:\Python27\lib\site-packages\scipy\__init__.py", line 61, in <module>
from numpy._distributor_init import NUMPY_MKL # requires numpy+mkl
ImportError: cannot import name NUMPY_MKL
I am using python 2.7 under windows 10.
I have installed scipy but that does not seem to solve the problem
Any help is appreciated.
If you look at the line which is causing the error, you'll see this:
from numpy._distributor_init import NUMPY_MKL # requires numpy+mkl
This line comment states the dependency as numpy+mkl (numpy with Intel Math Kernel Library). This means that you've installed the numpy by pip, but the scipy was installed by precompiled archive, which expects numpy+mkl.
This problem can be easy solved by installation for numpy+mkl from whl file from here.
Reinstall numpy-1.11.0_XXX.whl (for your Python) from www.lfd.uci.edu/~gohlke/pythonlibs. This file has the same name and version if compare with the variant downloaded by me earlier 29.03.2016, but its size and content differ from old variant. After re-installation error disappeared.
Second option - return back to scipy 0.17.0 from 0.17.1
P.S. I use Windows 64-bit version of Python 3.5.1, so can't guarantee that numpy for Python 2.7 is already corrected.
I'm not sure if this is a good solution but it removed the error.
I commented out the line:
from numpy._distributor_init import NUMPY_MKL
and it worked. Not sure if this will cause other features to break though
I had the same problem while installing gensim on windows. Gensim is dependent on scipy and scipy on numpy. Making all three work is real pain. It took me a lot of time to make all there work on same time.
Solution:
If you are using windows make sure you install numpy+mkl instead of just numpy.
If you have already installed scipy and numpy, uninstall then using "pip uninstall scipy" and "pip uninstall numpy"
Then download numpy-1.13.1+mkl-cp34-cp34m-win32.whl from http://www.lfd.uci.edu/~gohlke/pythonlibs/#numpy
and install using pip install numpy-1.13.1+mkl-cp34-cp34m-win32.wh
Note: in cp34-cp34m 34 represent the version of python you are using, so download the relevant version.
Now download scipy from http://www.lfd.uci.edu/~gohlke/pythonlibs/#scipy (appropriate version for your python and system)
and install using "pip install scipy‑0.19.1‑cp34‑cp34m‑win32.whl"
Your numpy and Scipy both should work now.
These binaries by Christoph Gohlke makes it very easy to install python packages on windows. But make sure you download all the dependent packages from there.
I don't have enough reputation to comment but I want to add, that the cp number of the .whl file stands for your python version.
cp35 -> Python 3.5.x
cp36 -> Python 3.6.x
cp37 -> Python 3.7.x
I think it's pretty obvious but still I wasted almost an hour because of this and maybe other people struggle with that, too.
So for me worked version cp36 that I downloaded here: https://www.lfd.uci.edu/~gohlke/pythonlibs/#numpy
since I am using Python 3.6.8.
Then I uninstalled numpy:
pip uninstall numpy
Then I installed numpy+mkl:
pip install <destination of your .whl file>
The reason for the error is you upgraded your numpy library of which there are some functionalities from scipy that are required by the current version for it to run which may not be found in scipy. Just upgrade your scipy library using python -m pip install scipy --upgrade. I was facing the same error and this solution worked on my python 3.5.
From your log its clear that numpy package is missing. As mention in the PyPI package:
The SciPy library depends on NumPy, which provides convenient and fast N-dimensional array manipulation.
So, try installing numpy package for python as you did with scipy.
I recently got the same error when trying to load scipy in jupyter (python3.x, win10), although just having upgraded to numpy-1.13.3+mkl through pip.
The solution was to simply upgrade the scipy package (from v0.19 to v1.0.0).
yes,Just reinstall numpy,it works.
I installed the python igraph library for anaconda following the directions in this thread installing python igraph, So the C core library and the python package were successfully installed. However, when I tried to import the igraph library in python, I am getting the following error
>>> import igraph
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/user/anaconda/lib/python2.7/site-packages/igraph/__init__.py", line 34, in <module>
from igraph._igraph import *
ImportError: dlopen(/Users/user/anaconda/lib/python2.7/site-packages/igraph/_igraph.so, 2): Library not loaded: libxml2.2.dylib
Referenced from: /Users/user/anaconda/lib/python2.7/site-packages/igraph/_igraph.so
Reason: Incompatible library version: _igraph.so requires version 12.0.0 or later, but libxml2.2.dylib provides version 10.0.0
Looking for similar threads, I found a similar issue here Installation of python igraph with lxml problem. However, there is not a clear way on how to solve this issue. Does anyone know how to fix it? Thanks in advance.
Anaconda Python is weird - it ships with its own version of libxml2 and when you run pip install python-igraph, igraph is probably linked against it. However, when you try to import igraph, the linker finds the system-wide libxml2, which has a lower ABI version, so that's why you see the error message.
The workaround for this is to ensure that during the compilation stage, Anaconda Python's libxml2 is not picked up by the compiler. setup.py in the Python interface of igraph actually contains this workaround - it tries to detect when you are compiling igraph against Anaconda Python on OS X and then it tweaks the environment a bit to ensure that the linker picks up the right version of libxml2. However, this workaround is enabled only if you do not have the C core of igraph installed on your machine - the installer will download the C core, tweak the environment to work around Anaconda Python, then compile the C core and the Python interface together in one single step.
So, the solution is probably one of the following:
Move Anaconda Python's libxml2 out of the way (or maybe rename xml2-config from Anaconda Python's distribution temporarily), then compile and install the C core from Homebrew. (Use brew unlink igraph, brew uninstall igraph, brew install igraph to be on the safe side). Then you can run pip install python-igraph.
Remove Homebrew's igraph entirely and just run pip install python-igraph - it will download the C core, perform the necessary tweaks and then compile everything.
I had exactly the same issue and installing/force linking libxml2 worked for me:
brew install libxml2
brew link --force libxml2
Others also report the same solution and it appears to be working.
I would like to try zeroRPC but couldn't install the package properly. I am using the latest python_xy distribution (python 2.7.3) under windows 7 and I must say I don't have much experience with installing new modules since the distribution is allready pretty complete.
I pulled the master zeroRPC-python from gitHub and tried to do "python setup.py install"
I had a first problem with something like "impossible to locate vcvarsall.bat". I solved it by installing mingw as explained here error: Unable to find vcvarsall.bat
Then I could run the install untill the end, but now, when I import zerorpc, I get the following ImportError (only the end of the stack):
C:\Python27\lib\site-packages\gevent-0.13.8-py2.7-win32.egg\gevent\greenlet.py in <module>()
4 import traceback
5 from gevent import core
----> 6 from gevent.hub import greenlet, getcurrent, get_hub, GreenletExit, Waiter
7 from gevent.timeout import Timeout
8
C:\Python27\lib\site-packages\gevent-0.13.8-py2.7-win32.egg\gevent\hub.py in <module>()
28
29 try:
---> 30 greenlet = __import__('greenlet').greenlet
31 except ImportError:
32 greenlet = __import_py_magic_greenlet()
ImportError: No module named greenlet
I wonder more generally if I am following the right procedure to install new packages (under windows) or if there is a simpler way (safer with dependancies) that I would be overlooking (easy_install)? I must say I am very new to this and any hints or link to the relevant documentation would be appreciated.
Thanks in advance,
Samuel
I was struggling with this question myself for a while now. The solution involves several components, and many answers out there seem to relate to different versions of those components that don't always play well together.
Here is the complete solution that worked for me, starting from an empty virtualenv:
mkvirtualenv myenv
python -m pip install --upgrade pip==6.0.8 wheel==0.24.0
pip install gevent-1.0.1-cp27-none-win32.whl pyzmq-13.1.0-cp27-none-win32.whl zerorpc==0.4.4
The first step installs wheel and upgrades pip itself to support wheel package installations. The next step installs binary wheels for gevent-1.0.1 (downloadable from this unofficial but extremely useful python windows binaries page) and pyzmq-13.1.0 (available here), and the zerorpc-0.4.4 package from source in the usual way.
Note that I hard-coded source package versions here (pip 6.0.8, wheel 0.24.0, zerorpc 0.4.4) because as I said other versions don't always follow the same build patterns. This may not be necessary and future versions may prove to work just as well together.
The final result for me:
(myenv) C:\work>pip freeze
gevent==1.0.1
greenlet==0.4.5
msgpack-python==0.4.5
pyzmq==13.1.0
wheel==0.24.0
zerorpc==0.4.4
I used a slightly different way, I am using Anaconda + Jupyter to run my python notebooks.
I used this link to zerorpc package, and installed using
conda install -c groakat zerorpc
which installed following -