I use Ubuntu 16.04 and installed Python3, numpy, pandas.
When I just entered 'import numpy', the following error came out.
Traceback (most recent call last):
File "regression1.py", line 3, in <module>
import numpy
File "/home/user/.local/lib/python3.5/site-packages/numpy/__init__.py", line 142, in <module>
from . import core
File "/home/user/.local/lib/python3.5/site-packages/numpy/core/__init__.py", line 59, in <module>
from . import numeric
File "/home/user/.local/lib/python3.5/site-packages/numpy/core/numeric.py", line 3093, in <module>
from . import fromnumeric
File "/home/user/.local/lib/python3.5/site-packages/numpy/core/fromnumeric.py", line 17, in <module>
from . import _methods
File "/home/user/.local/lib/python3.5/site-packages/numpy/core/_methods.py", line 158, in <module>
_NDARRAY_ARRAY_FUNCTION = mu.ndarray.__array_function__
AttributeError: type object 'numpy.ndarray' has no attribute '__array_function__'
Also When I just entered 'import pandas', the same error appeared. What should I do?
try to enter the following in the Terminal:
sudo apt-get install python3-numpy
I think you just got the lib for the wrong version of python
If you are not using virtual environment, try to reinstall the libraries using:
python3 -m pip install numpy pandas --user --force-reinstall
If you are using virtual environment, first you need to activate it before installing the libraries. This may be the case for example if you are using PyCharm to write your scripts (it suggests to make one when you create new project). If this is the case, first go to the folder with your project and activate the virtual environment using:
source venv/bin/activate
If your virtual environment has a different name than venv
, use that name instead.
Once it's activated, install the libraries using:
python -m pip install numpy pandas --force-reinstall
The error occurs if the numpy is not correctly installed in the designated folder.
The following works for Python 3 users Go to your python directory in cmd and run the following command:
py -3 -m pip install numpy
I hope this works for you too!!
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.