Under Ubuntu (12.04), installed python (2.7.5) with numpy (1.8rc2) using openblas into own environment (/din). The numpy site.cfg file is configured to point to openblas, and compiled as:
$ python setup.py build
$ sudo python setup.py install --prefix=/home/Programs/din/local
$ python
Python 2.7.5 (default, Oct 24 2013, 15:33:08)
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/Programs/din/local/lib/python2.7/site-packages/numpy/__init__.py", line 137, in <module>
import add_newdocs
File "/home/Programs/din/local/lib/python2.7/site-packages/numpy/add_newdocs.py", line 9, in <module>
from numpy.lib import add_newdoc
File "/home/Programs/din/local/lib/python2.7/site-packages/numpy/lib/__init__.py", line 4, in <module>
from type_check import *
File "/home/Programs/din/local/lib/python2.7/site-packages/numpy/lib/type_check.py", line 8, in <module>
import numpy.core.numeric as _nx
File "/home/Programs/din/local/lib/python2.7/site-packages/numpy/core/__init__.py", line 5, in <module>
import multiarray
ImportError:
"/home/Programs/din/local/lib/python2.7/site-packages/numpy/core/multiarray.so: undefined symbol: ERR_peek_last_error
Cython, gevent, and other python packages have all been installed successfully into /din but not numpy. The $PATH and python sys.path have been checked and all looks good.
Does anyone have ideas to try out?
This may not directly address your specific problem, but if you're on Ubuntu 12.04, you can just apt-get. Then, because the version will not be the latest, I then do pip install --upgrade. Doing apt-get before pip first magically seems to install the right dependencies as well; if I do pip install first, it doesn't work.
Specifically:
sudo apt-get install python-numpy python-scipy libblas-dev liblapack-dev gfortran python-dev
sudo pip install numpy --upgrade
sudo pip install scipy --upgrade
Related
Am having issues importing pandas on python3 on my raspberry pi. Whatever I try, I get the following error:
pi#raspberrypi:/ $ python3
Python 3.7.3 (default, Jul 25 2020, 13:03:44)
[GCC 8.3.0] on linux
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.7/dist-packages/pandas/__init__.py", line 22, in <module>
from pandas.compat import (
File "/usr/local/lib/python3.7/dist-packages/pandas/compat/__init__.py", line 15, in <module>
from pandas.compat.numpy import (
File "/usr/local/lib/python3.7/dist-packages/pandas/compat/numpy/__init__.py", line 7, in <module>
from pandas.util.version import Version
ModuleNotFoundError: No module named 'pandas.util'
It works fine on Python 2.7. I am getting errors with Python 3.7.3.
I searched Google and tried everything in the following post:
ImportError: No module named pandas
Some of the things I’ve tried are below - none have helped - I still get the error.
pip3 install pandas-util
pip3 install pandas.util
sudo apt-get install python3-wheel
sudo python3 -m pip install pandas
pip3 install pandas --upgrade
I've also tried uninstalling and reinstalling numpy and pandas - still get this error just with a basic import statement.
Any help would be appreciated as this is driving me insane!!
Cheers!
Try with
python3 -m pip install --force-reinstall pandas
This will ensure two things:
it will use the pip executable that belongs to the used Python executable, so that there is no accidental installation by another pip.
it will properly re-install Pandas.
Note that it doesn't re-download the Pandas package (it will use a cached version) if the version on PyPI hasn't changed between now and the previous installation. If that is a potential problem (incorrect cached file, for example), add the option --no-cache-dir to pip install.
I have this issue. I think it's best described when I show you my bash commands that I used to produce the problem. See here:
josch#oogway:~$ python
Python 2.7.9 (default, Jun 29 2016, 13:08:31)
[GCC 4.9.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import matplotlib
>>> #works
josch#oogway:~$ python3.5
Python 3.5.0 (default, Apr 26 2017, 21:03:53)
[GCC 4.9.2] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import matplotlib
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named 'matplotlib'
>>> #what??
Matplotlib was installed by:
sudo apt-get install python-matplotlib
The "default" python came with my OS installation, python3.5 was downloaded and then compiled/installed from source.
Can anyone help? Tried to solve it myselve for 2 hours now but google can't find answer
Edit: I'm trying to install a "second pip" that works with my second installation of Python, which is Python3.5. My default-Python that is managed by the OS is Python 2.7.9. Now, as suggested I did:
joschua#oogway:~/Downloads$ wget https://bootstrap.pypa.io/get-pip.py
and then:
python3.5 get-pip.py
which gave me:
joschua#oogway:~/Downloads$ python3.5 get-pip.py
Traceback (most recent call last):
File "get-pip.py", line 20061, in <module>
main()
File "get-pip.py", line 194, in main
bootstrap(tmpdir=tmpdir)
File "get-pip.py", line 82, in bootstrap
import pip
zipimport.ZipImportError: can't decompress data; zlib not available
Try installing pip3 with:
sudo apt-get install python3-pip
and then try installing matplotlib with:
sudo pip3 install matplotlib
I actually could solve the problem now.
See this link for a reasonable description on how to run two different versions of python on the same system (and as #Pierre de Buyl suggested) use two different pip versions on the same system
https://www.linkedin.com/pulse/20140815081557-89781742-how-to-install-and-use-python-with-different-versions-on-same-linux-machine
So, you installed python3.5 from source. What version of Debian are you using? (I suppose Jessie).
If you want to install packages for this Python interpreter, you must have a pip that actually uses it. Two solutions:
It is installed. If so,
python3.5 -m pip
will work and you can install packages with
python3.5 -m pip install matplotlib
or
python3.5 -m pip install --user matplotlib
It is not installed. You must install it following the instructions at https://packaging.python.org/installing/#requirements-for-installing-packages
apt-get will not install the appropriate pip for your needs. It will only install a pip that is related to the python3 (3.4 for jessie I believe) that is also in the apt-get system.
EDIT: in light of the update, you need also to re-compile python3.5 with zip enabled.
I tried to read all the issues concerning the python's error
ImportError: No module named
I reinstalled all the modules I need using
sudo apt-get install build-essential python-dev python-setuptools python-numpy python-scipy libatlas-dev libatlas3gf-base
I also upgraded using pip
sudo pip install --upgrade numpy
sudo pip install --upgrade scipy
When runing pip list I get
matplotlib (1.3.1)
scipy (0.17.0)
numpy (1.11.0)
But here is the execution result :
>>> import matplotlib
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named matplotlib
>>> import numpy
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.7/dist-packages/numpy/__init__.py", line 153, in <module>
from . import add_newdocs
File "/usr/lib/python2.7/dist-packages/numpy/add_newdocs.py", line 13, in <module>
from numpy.lib import add_newdoc
File "/usr/lib/python2.7/dist-packages/numpy/lib/__init__.py", line 8, in <module>
from .type_check import *
File "/usr/lib/python2.7/dist-packages/numpy/lib/type_check.py", line 11, in <module>
import numpy.core.numeric as _nx
File "/usr/lib/python2.7/dist-packages/numpy/core/__init__.py", line 6, in <module>
from . import multiarray
ImportError: /usr/lib/python2.7/dist-packages/numpy/core/multiarray.so: undefined symbol: PyUnicodeUCS4_AsUnicodeEscapeString
I don't know what's happening! please help!!
OS ubuntu14.04
NEW EDIT
So some news: I checked out the install of python and I found different versions in different places. In the python2.7 case I have :
/usr/bin/python2.7
/usr/local/bin/pyton2.7
While using which I get
which python
/usr/local/bin/python
But the /usr/bin/python2.7 works really fine
cd /usr/bin
./python2.7
Python 2.7.6 (default, Jun 22 2015, 17:58:13)
[GCC 4.8.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import scipy
>>> import numpy
>>> import matplotlib
>>>
Thanks
This happens when the package has C extensions and they were compiled for an interpreter which does not fit the Python version you're trying to run it with.
(assuming you're running on Linux/OS X)
You can try using a virtualenv to install the package for the current Python version you're running:
pip install virtualenv
virtualenv my_env
source my_env/bin/activate
pip install numpy
Or you can directly provide the explicit path to the Python version with which you installed numpy.
Note that /usr/lib/python2.7/dist-packages/numpy/core/multiarray.so is the C extension which failed to load which indicates the problem.
Also see Conflicting versions of python in ubuntu for how to compile Python for your needs.
Install matplotlib like this if pip3 install didn't work for you
sudo apt-get install python3-matplotlib
Note - before doing check inside site-packages are present or not locate python using
which python
I am trying to use pypy in a virtualenv for better performance in running my python program. I was able to install all the required modules, except for lxml
So far, I tried
pip install lxml
Also tried
pip install --upgrade lxml
It shows the following message at the end:
Successfully installed lxml-3.4.4
However, when I start pypy prompt and try to import lxml, I get the error:
(venv)➜ pypy pypy
Python 2.7.3 (2.2.1+dfsg-1ubuntu0.2, Dec 02 2014, 23:00:55)
[PyPy 2.2.1 with GCC 4.8.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
And now for something completely different: ``denial is rarely a good debugging
technique''
>>>> import lxml
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named lxml
>>>> from lxml import html
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named lxml
Update:
I am using ubuntu 14.04
Also, I have tried
sudo apt-get install pypy-dev
I had a similar problem. I got it working by running sudo apt-get install python-dev libxml2 libxml2-dev libxslt-dev and then pip install --upgrade lxml
I get the following error when I import pylab:
Python 2.7.2 (default, Oct 11 2012, 20:14:37)
[GCC 4.2.1 Compatible Apple Clang 4.0 (tags/Apple/clang-418.0.60)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import pylab
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Library/Python/2.7/site-packages/matplotlib-1.3.x-py2.7-macosx-10.8-intel.egg/pylab.py", line 1, in <module>
from matplotlib.pylab import *
File "/Library/Python/2.7/site-packages/matplotlib-1.3.x-py2.7-macosx-10.8-intel.egg/matplotlib/pylab.py", line 225, in <module>
import matplotlib.finance
File "/Library/Python/2.7/site-packages/matplotlib-1.3.x-py2.7-macosx-10.8-intel.egg/matplotlib/finance.py", line 23, in <module>
from matplotlib.collections import LineCollection, PolyCollection
File "/Library/Python/2.7/site-packages/matplotlib-1.3.x-py2.7-macosx-10.8-intel.egg/matplotlib/collections.py", line 23, in <module>
import matplotlib.backend_bases as backend_bases
File "/Library/Python/2.7/site-packages/matplotlib-1.3.x-py2.7-macosx-10.8-intel.egg/matplotlib/backend_bases.py", line 50, in <module>
import matplotlib.textpath as textpath
File "/Library/Python/2.7/site-packages/matplotlib-1.3.x-py2.7-macosx-10.8-intel.egg/matplotlib/textpath.py", line 11, in <module>
import matplotlib.font_manager as font_manager
File "/Library/Python/2.7/site-packages/matplotlib-1.3.x-py2.7-macosx-10.8-intel.egg/matplotlib/font_manager.py", line 1297
_fc_match_regex = re.compile(rb'\sfile:\s+"([^"]*)"')
^
SyntaxError: invalid syntax
Installed dependancies using homebrew
brew install freetype
brew install libpng
Installed matplotlib and numpy by cloning the github repo and doing:
sudo python setup.py build
sudo python setup.py install
Any help in resolving this issues is greatly appreciated.
There is a syntax error in that file. I guess you're using the development sources? That rb shouldn't be there before the regular expression (it should be r in Python 2.x, maybe b in Python 3.x).
UPDATE: Yep. Here's the faulty commit:
https://github.com/matplotlib/matplotlib/commit/2415c6200ebdba75a0571d71a4569f18153fff57
It should be br. This will be fixed in matplotlib master momentarily.
Trinity:
sudo pip install numpy
sudo pip install matplotlib
sudo pip install scipy
If you are using master to compile it run sudo brew update and then:
sudo brew install freetype
sudo brew install libpng
and then build and install:
sudo python setup.py build
sudo python setup.py install