gpt4 book ai didi

python - 无法使用 python3.2 导入 numpy

转载 作者:太空宇宙 更新时间:2023-11-04 03:50:02 24 4
gpt4 key购买 nike

<分区>

我有 Ubuntu 12.04,机器上构建了三种不同的 python(python2.7、python3、python3.2)。我只能在 python 2.7 中获取要导入的包。每当我尝试在 Python 3.2.3 中导入它们时,我都会得到:

Python 3.2.3 (default, Jan 14 2014, 13:11:14) 
[GCC 4.6.3] 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
>>>

我看到过关于 Stack 的各种类似问题的问题,但没有一个能解决我的问题。

例如,我运行了这段代码:

sudo apt-get install python3-numpy python3-scipy

结果是:

Reading package lists... Done
Building dependency tree
Reading state information... Done
python3-numpy is already the newest version.
python3-scipy is already the newest version.

看来我确实安装了 python3 的包,但无法将它们加载到 python3.2.3 环境中。

    >>> sys.path
['', '/usr/local/lib/python32.zip', '/usr/local/lib/python3.2',
'/usr/local/lib/python3.2/plat-linux2', '/usr/local/lib/python3.2/lib-dynload',
'/home/bre-dev-2/.local/lib/python3.2/site-packages', '/usr/local/lib/python3.2/site-packages']

所有站点包都是空的,而 numpy 和 scipy 存在于文件夹 usr/lib/python3/dist-packages 中(注意路径名中没有“本地”)。

最后,当我更改 sys.path 以包含带有 numpy 和 scipy 的目录时:

>>> sys.path[6]='/usr/lib/python3/dist-packages'
>>> import numpy
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python3/dist-packages/numpy/__init__.py", line 137, in <module>
from . import add_newdocs
File "/usr/lib/python3/dist-packages/numpy/add_newdocs.py", line 9, in <module>
from numpy.lib import add_newdoc
File "/usr/lib/python3/dist-packages/numpy/lib/__init__.py", line 4, in <module>
from .type_check import *
File "/usr/lib/python3/dist-packages/numpy/lib/type_check.py", line 8, in <module>
import numpy.core.numeric as _nx
File "/usr/lib/python3/dist-packages/numpy/core/__init__.py", line 5, in <module>
from . import multiarray
ImportError: cannot import name multiarray

有什么建议吗?开始失去理智....

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