This is driving me crazy. I have tried to remove all the packages of python installed on mac os x el capitan and re-installed brew install python and pip. Here I have :
which pip
/usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/bin/pip
and
which python
/usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/bin/python
so using pip list
pip list
cycler (0.10.0)
matplotlib (1.5.1)
numpy (1.11.0)
pip (8.1.2)
python-dateutil (2.5.3)
pytz (2016.4)
setuptools (19.4)
six (1.10.0)
wheel (0.26.0)
However, when I run python, there is no module called numpy and matplotlib:
python
Python 2.7.11 (default, Jan 22 2016, 08:29:18)
[GCC 4.2.1 Compatible Apple LLVM 7.0.2 (clang-700.1.81)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named numpy
>>> import matplotlib
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python2.7/site-packages/matplotlib/__init__.py", line 122, in <module>
from matplotlib.cbook import is_string_like, mplDeprecation, dedent, get_label
File "/usr/local/lib/python2.7/site-packages/matplotlib/cbook.py", line 33, in <module>
import numpy as np
ImportError: No module named numpy
and this is my sys.path:
sys.path
['', '/usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/lib/python27.zip', '/usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/lib/python2.7', '/usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-darwin', '/usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac', '/usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac/lib-scriptpackages', '/usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk', '/usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-old', '/usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload', '/usr/local/lib/python2.7/site-packages', '/usr/local/lib/python2.7/site-packages/gtk-2.0']
You can run pip with a specific version of Python by running it as a module. Command line arguments work just as if running directly from the command line. For example, try:
python -m pip list
If that still lists numpy it probably means there is something wrong with the numpy installation — i.e. the .egg file is there, but the module folder is not. To try and fix this you can use --force-reinstall with pip, e.g.
python -m pip install numpy --force-reinstall --upgrade
If that still doesn't work, you can resort to going to the folder reported by sys.path and deleting anything numpy related manually.
Since your pip setup seems messed up you might want to try reinstalling pip too!
The most accurate method is to call pip from the specific python executable. For example:
/usr/bin/python -m pip list -v
/usr/local/bin/python3 -m pip list -v
Related
I am trying to install Numba on a cluster so I can run my Jitted python codes on there. However I keep running into an error with "libllvmlite.so" when I try to import Numba. This is done on the Cedar cluster using virtualenv. Numba is installed using pip (and also tried pip3).
I start off my activating my enviroment using (... is the directory to my enviroment folder) :
source ~/.../ENV/bin/activate.
Then I use pip to install Numba (I've also tried used pip uninstall to remove and reinstall Numba).
However when I load up Python 3.7.0 on my enviroment, I obtain an error whenever I try to import Numba.
I use pip show to check versions: Python 3.7.0, Numba 0.53.1, llvmlite 0.36.0.
Here is the output of my terminal:
(ENV) [04:12:46] patrick7#cedar1 > [~/projects/def-mann/patrick7/diffusioncluster]python
Python 3.7.0 (default, Sep 25 2018, 18:19:16)
[GCC 5.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import numba
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/patrick7/projects/def-mann/patrick7/diffusioncluster/ENV/lib/python3.7/site-packages/numba/__init__.py", line 19, in <module>
from numba.core import config
File "/home/patrick7/projects/def-mann/patrick7/diffusioncluster/ENV/lib/python3.7/site-packages/numba/core/config.py", line 16, in <module>
import llvmlite.binding as ll
File "/home/patrick7/projects/def-mann/patrick7/diffusioncluster/ENV/lib/python3.7/site-packages/llvmlite/binding/__init__.py", line 4, in <module>
from .dylib import *
File "/home/patrick7/projects/def-mann/patrick7/diffusioncluster/ENV/lib/python3.7/site-packages/llvmlite/binding/dylib.py", line 3, in <module>
from llvmlite.binding import ffi
File "/home/patrick7/projects/def-mann/patrick7/diffusioncluster/ENV/lib/python3.7/site-packages/llvmlite/binding/ffi.py", line 191, in <module>
raise OSError("Could not load shared object file: {}".format(_lib_name))
OSError: Could not load shared object file: libllvmlite.so
I have tried other solutions found online (reinstall, try different versions...), so far none has worked. Any help would be greatly appreciated! Thanks!
I figured out the solution to my problem.
What I've tried and didn't work:
Install llvmlite using pip manually
Downgrade to Numba version 0.43 since its the oldest version compatible with Python 3.7
Uninstall (llvmlite numpy and numba) and reinstalling Numba (which automatically installs it's dependancies) after upgrading Pip to the latest version
What worked:
Upgrading Python from 3.7.0 to 3.7.10
It seems like for Python version >= 3.7.3, the default command pip install numba works flawlessly!
Thanks for reading!
I am trying to install opencv package on Raspberry Pi (Stratodesk OS). the best shot I got so far is through: https://www.piwheels.hostedpi.com/simple
However, after installing
pip install opencv-contrib-python --extra-index-url https://www.piwheels.hostedpi.com/simple
when importing the cv2 in python I get import error message related to libhdf5_serial.so.100:
root#PNAR55:~# python3
Python 3.5.2 (default, Nov 12 2018, 13:43:14)
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
import cv2
Traceback (most recent call last):
File "", line 1, in
File "/usr/local/lib/python3.5/dist-packages/cv2/init.py", line 3,
in
from .cv2 import *
ImportError: libhdf5_serial.so.100: cannot open shared object file: No
such file or directory
besides, I tried to install opencv-python but without success
pip install opencv-python --extra-index-url https://www.piwheels.hostedpi.com/simple
when importing cv2, I am getting a different ImportError message related to liblapack.so.3
import cv2
Traceback (most recent call last): File "", line
1, in File
"/usr/local/lib/python3.5/dist-packages/cv2/init.py", line 3, in
from .cv2 import * ImportError: liblapack.so.3: cannot open shared object file: No such file or directory
for your information, Stratodesk OS is quite different that Raspbian. I do not have git, cmake, apt-get commands.
if there is a way to overcome the error messages I am getting
This problem is due to an incompatibility between your board and the OpenCV version. If you installed it via pip try pip uninstall opencv-python or pip3 uninstall opencv-python (depending of the python version you need (pip for python2 and pip for python3). After uninstaling is complete, try to search for an older version of opencv and install via pip3 install opencv-python==3.4.6.27 (this is the version that worked for me. I'm almost sure you'll need another one). Also, check this link, and this one!
I installed python3.6 under OpenBSDd6.4 for data analysis(is it a good idea?)
Since Anaconda is not working under OpenBSD, I install pip to manage python package.
I use pkg_add -v python to install python3.6.6
pip install pandas
the code above bring me the newest pandas version 0.23.4 and numpy 1.15.4.
when I use the import pandas,the wrong message comes out.
Python 3.6.6 (default, Oct 11 2018, 16:49:21)
[GCC 4.2.1 Compatible OpenBSD Clang 6.0.0 (tags/RELEASE_600/final)] on openbsd6
Type "help", "copyright", "credits" or "license" for more information.
>>> import pandas
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.6/site-packages/pandas/__init__.py", line 26, in <module>
from pandas._libs import (hashtable as _hashtable,
File "/usr/local/lib/python3.6/site-packages/pandas/_libs/__init__.py", line 4, in <module>
from .tslib import iNaT, NaT, Timestamp, Timedelta, OutOfBoundsDatetime
File "__init__.pxd", line 872, in init pandas._libs.tslib
ValueError: numpy.ufunc has the wrong size, try recompiling. Expected 112, got 124
>>>
I check the location and version of numpy with command,
>>> import numpy
>>> numpy.__file__
'/usr/local/lib/python3.6/site-packages/numpy/__init__.py'
>>> numpy.version.version
'1.15.4'
I google some resolution like,
pip uninstall pandas
pip uninstall numpy
pip install pandas -U
but failed.
pip install --upgrade --force-reinstall pandas
above command,failed.
https://stackoverflow.com/questions/53904157/numpy-ufunc-has-the-wrong-size-try-recompiling-even-with-the-latest-pandas-and
above url failed.
Would you mind give me a hint on how to solve this probelms?
Is it a good choice to use OpenBSD as a data analysis platform?
Thank you.
I had the same issue with numpy 1.14.5, I solved it with installing numpy 1.16.5
pip3.4 install numpy==1.16.5
Running my script (which imports ply) with python 2.7 works without issue. But trying to run the same script with python3 causes the following. (Note: I'm on v3.10 of ply - the latest which should be compatible with python3).
bos-mpqpu:config_parse rabdelaz$ python3 lexparse.py
Traceback (most recent call last):
File "lexparse.py", line 1, in <module>
import ply.lex as lex
ModuleNotFoundError: No module named 'ply'
bos-mpqpu:config_parse rabdelaz$ pip show ply | grep Version
Version: 3.10
I've installed python3:
bos-mpqpu:config_parse rabdelaz$ python3
Python 3.6.2 (v3.6.2:5fd33b5926, Jul 16 2017, 20:11:06)
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import ply
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'ply'
>>>
Try this command if you have pip3
pip3 install ply
This works too:
python3 -m pip install ply
You must install this module for python3.
Python modules, libraries are different for python 2 and 3.
for linux installation:
python 2.7.x : sudo apt-get install python-ply
python 3.x : sudo apt-get install python3-ply
https://www.howtoinstall.co/en/ubuntu/utopic/python-ply
I was facing the same issue but couldn't exactly know what was the problem so I again installed ply library and went to its location and made my project there. Library worked well there.
Install ply library
pip3 install ply
this would show you where the library is stored after successful installation.
Go to the location and make your project their.
This worked for me. Hopefully it would help you too.
I installed psycopg2 via pip, but my programs are having trouble finding it.
So, I tried to install psycopg2 via pip again:
user#ubuntu:~/Desktop/progFolder$ sudo pip install psycopg2
Requirement already satisfied (use --upgrade to upgrade): psycopg2 in /usr/local/lib/python2.7/dist-packages
Cleaning up...
Then I tried to use a program that imports it:
user#ubuntu:~/Desktop/progFolder$ python myProg.py
Traceback (most recent call last):
File "myProg.py", line 6, in <module>
import psycopg2
ImportError: No module named psycopg2
And I have tried just importing directly in python:
user#ubuntu:~/Desktop/progFolder$ python
Python 2.7.5 (default, Nov 9 2014, 14:14:12)
[GCC 4.8.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import psycopg2
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named psycopg2
So I printed my python path.
>>> import sys
>>> print sys.path
['', '/usr/local/lib/python27.zip', '/usr/local/lib/python2.7', '/usr/local/lib/python2.7/plat-linux2', '/usr/local/lib/python2.7/lib-tk', '/usr/local/lib/python2.7/lib-old', '/usr/local/lib/python2.7/lib-dynload', '/usr/local/lib/python2.7/site-packages']
And noticed that the path does contain the path to psycopg2.
psycopg2 in /usr/local/lib/python2.7/dist-packages
So, I have no idea on why this is happening. Any help would be appreciated.
UPDATE:
I have done
>>>help()
>>>modules
And psycopg2 was not listed among the other modules. (this does not help me but may help you help me)
Your pip looks ok (that is, it's the system/default one). Your Python executable, however, is something that didn't come by default with 14.04 LTS (e.g., on my 14.04 system, it's /usr/bin/python). Did you install that Python yourself? Then you need to install (and use) the corresponding pip as well. (Normally, Python would have come with a pip installation, but apparently in this case, it didn't.)
pip can be fairly simple installed from its installation instructions.
Though first, verify that
you did install /usr/local/bin/python yourself. That is, it didn't come with some other piece of software that you installed and that, along the way, decided to install Python there.
you want to use /usr/local/bin/python (I guess it is a more recent version of Python 2.7; the default 14.04 LTS one appears to be 2.6.7 as of 2015-08-03).
From your python path print, it looks like it doesn't have /usr/local/lib/python2.7/dist-packages included in it. You can add it in one way by:
sys.path.insert(0, "/usr/local/lib/python2.7/dist-packages")