我正在尝试在我的mac机器上安装numpy。 无论我尝试什么,我最终都会在尝试运行我的python代码时出现此错误
import numpy as np
File "/Library/Python/2.6/site-packages/numpy-2.0.0.dev_26aa3cf_20110808-py2.7-macosx-
10.7-x86_64.egg/numpy/__init__.py", line 137, in <module>
import add_newdocs
File "/Library/Python/2.6/site-packages/numpy-2.0.0.dev_26aa3cf_20110808-py2.7-macosx-
10.7-x86_64.egg/numpy/add_newdocs.py", line 9, in <module>
from numpy.lib import add_newdoc
File "/Library/Python/2.6/site-packages/numpy-2.0.0.dev_26aa3cf_20110808-py2.7-macosx-
10.7-x86_64.egg/numpy/lib/__init__.py", line 4, in <module>
from type_check import *
File "/Library/Python/2.6/site-packages/numpy-2.0.0.dev_26aa3cf_20110808-py2.7-macosx-
10.7-x86_64.egg/numpy/lib/type_check.py", line 8, in <module>
import numpy.core.numeric as _nx
File "/Library/Python/2.6/site-packages/numpy-2.0.0.dev_26aa3cf_20110808-py2.7-macosx-
10.7-x86_64.egg/numpy/core/__init__.py", line 5, in <module>
import multiarray
ImportError: dlopen(/Library/Python/2.6/site-packages/numpy-2.0.0.dev_26aa3cf_20110808-py2.7-
macosx-10.7-x86_64.egg/numpy/core/multiarray.so, 2): Symbol not found: _PyCapsule_Import
Referenced from: /Library/Python/2.6/site-packages/numpy-2.0.0.dev_26aa3cf_20110808-py2.7-macosx-10.7-x86_64.egg/numpy/core/multiarray.so
Expected in: flat namespace
in /Library/Python/2.6/site-packages/numpy-2.0.0.dev_26aa3cf_20110808-py2.7-macosx-
10.7-x86_64.egg/numpy/core/multiarray.so
当我在终端中输入Python时,我需要使用python 2.6.1版本。 我该如何解决这个问题?
答案 0 :(得分:2)
根据错误消息中的路径,您似乎打算为已安装的Python 2.7安装Numpy。你得到的是Python 2.6。这表明您的PATH
环境变量存在问题。调整PATH
中的.bash_profile
变量,以便Python 2.7的可执行文件出现在/usr/bin
中的系统版本之前。
答案 1 :(得分:1)
使用macports,安装numpy就像
一样简单cd /opt/local/bin
sudo ./port install py27-numpy
其中py27可以替换为您最喜欢的python版本。
答案 2 :(得分:0)
如果你想在你的Mac上有一个相当完整的科学python环境,我会推荐EPD免费的Python发行版。这会给你带来n and和scipy等。