为什么即使终端说“要求已经满足",我仍然不能使用NumPy模块? [英] why i still can't use the NumPy module even the terminal says "requirement already satisfied"?

查看:530
本文介绍了为什么即使终端说“要求已经满足",我仍然不能使用NumPy模块?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用

pip install numpy

在我的Mac上安装NumPy.然后终端说

to install NumPy on my Mac. Then the terminal says that

Requirement already satisfied: numpy in 
/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python

我猜这意味着已经安装了Numpy吗? 但是当我写

I guess it means Numpy is already installed? but when i wrote

from numpy import array
a=array([1,3],int)

python shell说

the python shell says

Traceback (most recent call last):
File "/Users/bamford/Documents/python/untitled-3.py", line 1, in <module>
from numpy import array
builtins.ModuleNotFoundError: No module named 'numpy'

怎么回事?

推荐答案

每个

Per the comments, notice that your sys.path includes directories whose names imply they are associated with Python3.6:

[...'/Library/Frameworks/Python.framework/版本/3.6/lib/pytho‌n36.zip',...]

[... '/Library/Frameworks/Python.framework/Versions/3.6/lib/pytho‌​n36.zip', ...]

尚未在您的Python2.7发行版中安装NumPy:

Yet NumPy has been installed in your Python2.7 distribution:

已满足要求:输入numpy /System/Library/Frameworks/Python.framework/版本/2.7 /Extras/lib/python

Requirement already satisfied: numpy in /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python

(我的重点是)您的Wing101 IDE使用的是Python3,但未找到NumPy,因为尚未(尚未)在您的Python3发行版中安装NumPy.

(my emphasis) So your Wing101 IDE is using Python3, and not finding NumPy because NumPy has not (yet) been installed in your Python3 distribution.

一种解决方案是为您的Python3发行版安装NumPy. (另一个可能是将Wing101配置为运行Python2.7.)通常,与Python3关联的pip可执行文件名为pip3(以将其与称为pip的Python2版本区分开.)因此,您可以尝试

One solution would be to install NumPy for your Python3 distribution. (Another, might be to configure Wing101 to run Python2.7.) Often, the pip executable associated with Python3 is named pip3 (to distinguish it from a Python2 version called pip.) So you might try

pip3 install numpy

安装NumPy.

故事的寓意:每个点都与特定的Python发行版本相关. pip是Python脚本.运行时,它将调用与该发行版关联的Python可执行文件.

Moral of the story: Every pip is associated with a particular Python distribution. pip is a Python script. When run, it calls the Python executable associated with that distribution.

要使用pip为特定的Python安装模块,您需要调用与所需的Python可执行文件关联的pip脚本.

To install modules for a particular Python using pip, you need to call the pip script which is associated with the desired Python executable.

这篇关于为什么即使终端说“要求已经满足",我仍然不能使用NumPy模块?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆