gpt4 book ai didi

已安装包的 Python ImportError

转载 作者:行者123 更新时间:2023-12-04 19:15:42 34 4
gpt4 key购买 nike

安装numpy表示已经是最新版本,出现在pip list返回的列表中也是,但是导入它会产生导入错误(并且这个问题对于每个其他已安装的模块都存在,例如 scipy、matplotlib)。

系统有什么问题以及如何解决?

sunny@sunny:~$ pip list
adium-theme-ubuntu (0.3.4)
cycler (0.9.0)
decorator (4.0.6)
matplotlib (1.5.1)
numpy (1.11.0)
Pillow (3.1.2)
pip (8.1.1)
pyeemd (1.3.1)
pyparsing (2.0.3)
python-dateutil (2.4.2)
pytz (2014.10)
scipy (0.17.0)
setuptools (20.7.0)
six (1.10.0)
unity-lens-photos (1.0)
wheel (0.29.0)
sunny@sunny:~$ python
Python 2.7.11 (default, May 28 2016, 17:16:00)
[GCC 5.3.1 20160413] 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
>>> quit()
sunny@sunny:~$ sudo apt-get install python-numpy
Reading package lists... Done
Building dependency tree
Reading state information... Done
python-numpy is already the newest version (1:1.11.0-1ubuntu1).
0 upgraded, 0 newly installed, 0 to remove and 5 not upgraded.
sunny@sunny:~$

编辑:我尝试在我的 Ubuntu 系统上将 pip3 用于 python3 以使导入工作(我以前从未接触过 python3),我再次得到与上面相同的旧结果,即
sunny@sunny:~$ pip3 install numpy
Collecting numpy
Downloading numpy-1.11.1-cp35-cp35m-manylinux1_x86_64.whl (15.6MB)
100% |████████████████████████████████| 15.6MB 57kB/s
Installing collected packages: numpy
Successfully installed numpy
You are using pip version 8.1.1, however version 8.1.2 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
sunny@sunny:~$ python
Python 2.7.11 (default, May 28 2016, 17:16:00)
[GCC 5.3.1 20160413] 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
>>> quit()
sunny@sunny:~$ pip3 list
apturl (0.5.2)
beautifulsoup4 (4.4.1)
blinker (1.3)
Brlapi (0.6.4)
chardet (2.3.0)
checkbox-support (0.22)
command-not-found (0.3)
cryptography (1.2.3)
defer (1.0.6)
feedparser (5.1.3)
guacamole (0.9.2)
html5lib (0.999)
httplib2 (0.9.1)
idna (2.0)
Jinja2 (2.8)
language-selector (0.1)
louis (2.6.4)
lxml (3.5.0)
Mako (1.0.3)
MarkupSafe (0.23)
numpy (1.11.1)
oauthlib (1.0.3)
onboard (1.2.0)
padme (1.1.1)
pexpect (4.0.1)
Pillow (3.1.2)
pip (8.1.1)
plainbox (0.25)
ptyprocess (0.5)
pyasn1 (0.1.9)
pycups (1.9.73)
pycurl (7.43.0)
pygobject (3.20.0)
PyJWT (1.3.0)
pyparsing (2.0.3)
python-apt (1.1.0b1)
python-debian (0.1.27)
python-systemd (231)
pyxdg (0.25)
reportlab (3.3.0)
requests (2.9.1)
sessioninstaller (0.0.0)
setuptools (20.7.0)
six (1.10.0)
system-service (0.3)
ubuntu-drivers-common (0.0.0)
ufw (0.35)
unattended-upgrades (0.1)
unity-scope-calculator (0.1)
unity-scope-chromiumbookmarks (0.1)
unity-scope-colourlovers (0.1)
unity-scope-devhelp (0.1)
unity-scope-firefoxbookmarks (0.1)
unity-scope-gdrive (0.7)
unity-scope-manpages (0.1)
unity-scope-openclipart (0.1)
unity-scope-texdoc (0.1)
unity-scope-tomboy (0.1)
unity-scope-virtualbox (0.1)
unity-scope-yelp (0.1)
unity-scope-zotero (0.1)
urllib3 (1.13.1)
usb-creator (0.3.0)
wheel (0.29.0)
xdiagnose (3.8.4)
xkit (0.0.0)
XlsxWriter (0.7.3)
You are using pip version 8.1.1, however version 8.1.2 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
sunny@sunny:~$

最佳答案

你为 python3.5.* 安装了 numpy,但是你在 python2.7.11 中导入了它。不是吗?

sunny@sunny:~$ pip3 install numpy
Collecting numpy
Downloading numpy-1.11.1-cp35-cp35m-manylinux1_x86_64.whl (15.6MB)
100% |████████████████████████████████| 15.6MB 57kB/s
Installing collected packages: numpy
Successfully installed numpy

名称“numpy-1.11.1-cp35-cp35m-manylinux1_x86_64.whl”中的“cp35”表示它适用于 python3.5.* 。
sunny@sunny:~$ python
Python 2.7.11 (default, May 28 2016, 17:16:00)
[GCC 5.3.1 20160413] 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

但是在这里,您输入“python”,然后打开 python2.7.11 而不是 python3.5.* 。
所以尝试“cd”到python3.5.*的安装目录,然后输入“python3.5.exe”。
希望对你有所帮助。

关于已安装包的 Python ImportError,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38189143/

34 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com