我想使用 Python 工作。当我导入 scipy 或 numpy 时,它显示以下错误:
saikat@saikat:~/Downloads/Python-2.7.15$ python
Python 2.7.14 |Anaconda, Inc.| (default, Dec 7 2017, 17:05:42)
[GCC 7.2.0] on linux2
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
>>>
但是当我使用这个命令时:
sudo pip install numpy scipy
表明:
saikat@saikat:~/Downloads/Python-2.7.15$ sudo pip install numpy scipy
The directory '/home/saikat/.cache/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
The directory '/home/saikat/.cache/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Requirement already satisfied: numpy in /usr/local/lib/python2.7/dist-packages/numpy-1.14.3-py2.7-linux-x86_64.egg (1.14.3)
Requirement already satisfied: scipy in /usr/local/lib/python2.7/dist-packages (1.1.0).
我应该怎么办?
答案1
conda
您有 Anaconda Python 而不是系统 Python 版本。由于您使用 Anaconda,因此您的软件包应使用或 Anacondapip
版本安装。使用base
默认 Anaconda 安装的环境,Numpy 和 Scipy 已安装,如果没有:
conda install numpy scipy