Week before perfectly working numpy stopped working under Python 3.7 on Raspbian GNU/Linux 10 (buster). Still works with Python 2.7.
~ $ python3
Python 3.7.3 (default, Apr 3 2019, 05:39:12)
[GCC 8.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy
Traceback (most recent call last):
File "/usr/local/lib/python3.7/dist-packages/numpy/core/__init__.py", line 24, in <module>
from . import multiarray
File "/usr/local/lib/python3.7/dist-packages/numpy/core/multiarray.py", line 14, in <module>
from . import overrides
File "/usr/local/lib/python3.7/dist-packages/numpy/core/overrides.py", line 7, in <module>
from numpy.core._multiarray_umath import (
ImportError: libf77blas.so.3: cannot open shared object file: No such file or directory
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.7/dist-packages/numpy/__init__.py", line 142, in <module>
from . import core
File "/usr/local/lib/python3.7/dist-packages/numpy/core/__init__.py", line 54, in <module>
raise ImportError(msg)
ImportError:
IMPORTANT: PLEASE READ THIS FOR ADVICE ON HOW TO SOLVE THIS ISSUE!
Importing the numpy c-extensions failed.
- Try uninstalling and reinstalling numpy.
- If you have already done that, then:
1. Check that you expected to use Python3.7 from "/usr/bin/python3",
and that you have no directories in your PATH or PYTHONPATH that can
interfere with the Python and numpy version "1.18.1" you're trying to use.
2. If (1) looks fine, you can open a new issue at
https://github.com/numpy/numpy/issues. Please include details on:
- how you installed Python
- how you installed numpy
- your operating system
- whether or not you have multiple versions of Python installed
- if you built from source, your compiler versions and ideally a build log
- If you're working with a numpy git repository, try `git clean -xdf`
(removes all files not under version control) and rebuild numpy.
Note: this error has many possible causes, so please don't comment on
an existing issue about this - open a new one instead.
Original error was: libf77blas.so.3: cannot open shared object file: No such file or directory
Tried to reinstall:
~ $ sudo pip3 uninstall -y numpy
Uninstalling numpy-1.18.1:
Successfully uninstalled numpy-1.18.1
~ $ sudo pip3 install numpy
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Collecting numpy
Using cached https://www.piwheels.org/simple/numpy/numpy-1.18.1-cp37-cp37m-linux_armv7l.whl
Installing collected packages: numpy
Successfully installed numpy-1.18.1
Did not work.
Tried first reinstalling setuptools using sudo pip3 uninstall -y setuptools, returns:
Not uninstalling setuptools at /usr/lib/python3/dist-packages, outside environment /usr
Can't uninstall 'setuptools'. No files were found to uninstall.
But when I try to install it using sudo pip3 install setuptools, returns:
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Requirement already satisfied: setuptools in /usr/lib/python3/dist-packages (40.8.0)
I am confused, do not know what to do.
Related
I have an M1 Mac. My program was running fine in PyCharm when using the Intel-based dmg. PyCharm kept notifying me to upgrade to the version optimized for Apple Silicon. PyCharm opened noticeably smoother. But trying to run my script now gives me an ImportError for "sounddevice" library. I tried to pip uninstall/reinstall, but made no difference. How can I fix this?
Traceback (most recent call last):
File "/Users/anonymous/PycharmProjects/ChineseTranscriber/main.py", line 2, in <module>
import sounddevice
File "/Users/anonymous/PycharmProjects/ChineseTranscriber/venv/lib/python3.9/site-packages/sounddevice.py", line 58, in <module>
from _sounddevice import ffi as _ffi
File "/Users/anonymous/PycharmProjects/ChineseTranscriber/venv/lib/python3.9/site-packages/_sounddevice.py", line 2, in <module>
import _cffi_backend
ImportError: dlopen(/Users/anonymous/PycharmProjects/ChineseTranscriber/venv/lib/python3.9/site-packages/_cffi_backend.cpython-39-darwin.so, 0x0002): tried: '/Users/anonymous/PycharmProjects/ChineseTranscriber/venv/lib/python3.9/site-packages/_cffi_backend.cpython-39-darwin.so' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64')), '/System/Volumes/Preboot/Cryptexes/OS/Users/anonymous/PycharmProjects/ChineseTranscriber/venv/lib/python3.9/site-packages/_cffi_backend.cpython-39-darwin.so' (no such file), '/Users/anonymous/PycharmProjects/ChineseTranscriber/venv/lib/python3.9/site-packages/_cffi_backend.cpython-39-darwin.so' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64'))
Process finished with exit code 1
By default, pip install installed the latest version (as of the time of this post, version 0.4.5)
python3 -m pip install sounddevice
Documentation states that version 0.4.3 added the a "universal" .dylib for macOs: https://readthedocs.org/projects/python-sounddevice/downloads/pdf/latest/
However, version 0.4.5 seemed to unintendedly revert/negatively affect the necessary change in 0.4.3.
Uninstalling sounddevice and specifying the reinstall to use version 0.4.3 fixed the issue
python3 -m pip uninstall sounddevice
python3 -m pip install -Iv sounddevice==0.4.3
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 am taking a course that uses a racecar simulator and I need to run some pre-built code that uses a custom library and also numpy. When I try to run the code on Ubuntu I get the following error:
Traceback (most recent call last):
File "/mnt/c/Users/seb/documents/Racecar/racecar-seb-h-s/labs/../library/numpy/core/__init__.py", line 22, in <module>
from . import multiarray
File "/mnt/c/Users/seb/documents/Racecar/racecar-seb-h-s/labs/../library/numpy/core/multiarray.py", line 12, in <module>
from . import overrides
File "/mnt/c/Users/seb/documents/Racecar/racecar-seb-h-s/labs/../library/numpy/core/overrides.py", line 7, in <module>
from numpy.core._multiarray_umath import (
ModuleNotFoundError: No module named 'numpy.core._multiarray_umath'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "demo.py", line 16, in <module>
import racecar_core
File "/mnt/c/Users/seb/documents/Racecar/racecar-seb-h-s/labs/../library/racecar_core.py", line 13, in <module>
import camera
File "/mnt/c/Users/seb/documents/Racecar/racecar-seb-h-s/labs/../library/camera.py", line 11, in <module>
import numpy as np
File "/mnt/c/Users/seb/documents/Racecar/racecar-seb-h-s/labs/../library/numpy/__init__.py", line 150, in <module>
from . import core
File "/mnt/c/Users/seb/documents/Racecar/racecar-seb-h-s/labs/../library/numpy/core/__init__.py", line 48, in <module>
raise ImportError(msg)
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 "/usr/bin/python3"
* The NumPy version is: "1.21.2"
and make sure that they are the versions you expect.
Please carefully study the documentation linked above for further help.
Original error was: No module named 'numpy.core._multiarray_umath'
I have tried all the other potential duplicates that I could find and used the link but none worked. I have also tried uninstalling and reinstalling and updating numpy to no avail.
The output of running the command echo $PATH was the following:
/home/seb/.local/bin
:/usr/local/sbin
:/usr/local/bin
:/usr/sbin
:/usr/bin
:/sbin
:/bin
:/usr/games
:/usr/local/games
:/mnt/c/Program Files/WindowsApps/CanonicalGroupLimited.UbuntuonWindows_2004.2021.825.0_x64__79rhkp1fndgsc:/mnt/c/Program Files/Java/jdk-13.0.1/bin.
:/mnt/c/Program Files (x86)/Common Files/Oracle/Java/javapath
:/mnt/c/Program Files (x86)/Common Files/Intel/Shared Libraries/redist/intel64/compiler:/mnt/c/WINDOWS/system32
:/mnt/c/WINDOWS
:/mnt/c/WINDOWS/System32/Wbem
:/mnt/c/WINDOWS/System32/WindowsPowerShell/v1.0/
:/mnt/c/WINDOWS/System32/OpenSSH/
:/mnt/c/Users/seb/anaconda3
:/mnt/c/Users/seb/anaconda3/Library/mingw-w64/bin
:/mnt/c/Users/seb/anaconda3/Library/usr/bin
:/mnt/c/Users/seb/anaconda3/Library/bin
:/mnt/c/Users/seb/anaconda3/Scripts
:/mnt/c/Users/seb/AppData/Local/Microsoft/WindowsApps
:/snap/bin
The output of running the command python3 -m site was the following:
sys.path = [
'/mnt/c/Users/seb/documents/Racecar/racecar-seb-h-s/labs',
'/usr/lib/python38.zip',
'/usr/lib/python3.8',
'/usr/lib/python3.8/lib-dynload',
'/home/seb/.local/lib/python3.8/site-packages',
'/usr/local/lib/python3.8/dist-packages',
'/usr/lib/python3/dist-packages',
]
USER_BASE: '/home/seb/.local' (exists)
USER_SITE: '/home/seb/.local/lib/python3.8/site-packages' (exists)
ENABLE_USER_SITE: True
This has happened to me as well because I am taking the same course. I solved it by uninstalling all the libraries and installing them again. Here is the link to the setup instructions: https://mitll-racecar-mn.readthedocs.io/en/latest/gettingStarted/computerSetup/python.html. These are the commands you have to run to install the libraries:
sudo apt update
sudo apt install python3.8
sudo apt install python3-pip
pip3 install --upgrade pip
pip3 install numpy
pip3 install matplotlib
pip3 install mypy
pip3 install nptyping
pip3 install opencv-contrib-python
pip3 install jupyter
pip3 install ipywidgets
jupyter nbextension enable --py widgetsnbextension
On an RPi2, I upgraded all my packages with pip-review and numpy does not work anymore.
I tried to uninstall and reinstall numpy though pip and apt but I'm getting no luck.
Apt installs numpy 1.12.1, if I try to install that it does not install through pip.
Pip installs numpy 1.16.4 fine, but when I go to run it I get the error below.
I have already run: sudo apt install libc6 libatlas-base-dev
Any help is appreciated.
Python 3.7.3 (default, May 8 2019, 18:07:21)
[GCC 6.3.0 20170516] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy
Traceback (most recent call last):
File "/usr/local/lib/python3.7/site-packages/numpy/core/__init__.py", line 40, in <module>
from . import multiarray
File "/usr/local/lib/python3.7/site-packages/numpy/core/multiarray.py", line 12, in <module>
from . import overrides
File "/usr/local/lib/python3.7/site-packages/numpy/core/overrides.py", line 6, in <module>
from numpy.core._multiarray_umath import (
ImportError: /lib/arm-linux-gnueabihf/libm.so.6: version `GLIBC_2.27' not found (required by /usr/local/lib/python3.7/site-packages/numpy/core/_multiarray_umath.cpython-37m-arm-linux-gnueabihf.so)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.7/site-packages/numpy/__init__.py", line 142, in <module>
from . import core
File "/usr/local/lib/python3.7/site-packages/numpy/core/__init__.py", line 71, in <module>
raise ImportError(msg)
ImportError:
IMPORTANT: PLEASE READ THIS FOR ADVICE ON HOW TO SOLVE THIS ISSUE!
Importing the multiarray numpy extension module failed. Most
likely you are trying to import a failed build of numpy.
Here is how to proceed:
- If you're working with a numpy git repository, try `git clean -xdf`
(removes all files not under version control) and rebuild numpy.
- If you are simply trying to use the numpy version that you have installed:
your installation is broken - please reinstall numpy.
- If you have already reinstalled and that did not fix the problem, then:
1. Check that you are using the Python you expect (you're using /usr/local/bin/python3),
and that you have no directories in your PATH or PYTHONPATH that can
interfere with the Python and numpy versions you're trying to use.
2. If (1) looks fine, you can open a new issue at
https://github.com/numpy/numpy/issues. Please include details on:
- how you installed Python
- how you installed numpy
- your operating system
- whether or not you have multiple versions of Python installed
- if you built from source, your compiler versions and ideally a build log
Note: this error has many possible causes, so please don't comment on
an existing issue about this - open a new one instead.
Original error was: /lib/arm-linux-gnueabihf/libm.so.6: version `GLIBC_2.27' not found (required by /usr/local/lib/python3.7/site-packages/numpy/core/_multiarray_umath.cpython-37m-arm-linux-gnueabihf.so)
pip install numpy --global-option="-mfloat-abi=hard" --force-reinstall was the only answer that worked for me . The explanation is given in a thread on a slightly different problem see this link
With Conda it is solved depending on the version, but must force reinstall.
# versions >= 4.6:
conda install numpy --force-reinstall
# versions < 4.6:
conda install numpy --force
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