port在macOS上安装的路径在哪里?
我在我的Mac上通过port安装了scipy,系统提示一切正常:
$ sudo port install py-scipy
Password:
---> Computing dependencies for py-scipy
---> Cleaning py-scipy
但是当我打开python时,它却找不到这个库:
$ python2.6
Python 2.6.7 (r267:88850, Jul 27 2011, 11:54:59)
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import scipy
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named scipy
我的路径里包含了我在网上找到的port位置:
... '/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python26.zip', '/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6', '/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/plat-darwin', '/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/plat-mac', '/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/plat-mac/lib-scriptpackages', '/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/lib-tk', '/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/lib-old', '/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/lib-dynload', '/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages', '/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/setuptools-0.6c11-py2.6.egg-info', ...
实际上,我在/opt/local/Library/Frameworks等路径下根本找不到scipy的文件。
有什么建议吗?
3 个回答
0
你安装的Python模块不在标准OS X版本的Python的搜索路径里。当你通过MacPorts安装一个Python模块时,它会安装自己版本的Python。你可以通过使用select
命令来开始使用MacPorts的版本:
sudo port select python python26
另外一个选择是使用标准Python的easy_install来安装它。
0
想要了解更多信息,可以搜索一下 macports.conf
,里面会有你需要的所有资料。你也可以输入 man macports.conf
来查看一些具体的细节。
3
如果你想把现在用的Python版本换成通过MacPorts安装的版本,可以这样做:
sudo port select python python26
这样一来,你就可以使用MacPorts安装的Python版本了,这个版本里已经装好了scipy这个库。