我试了很长时间在这台Mac上使用python。我试图从我的mac中完全删除python。然后我意识到很难摆脱这个默认的python。幸运的是,我在互联网上读到,在我弄清楚如何删除它之前删除Mac附带的那个python是个坏主意。然后我还使用* .dmg软件包安装了python,numpy,scipy,matplotlib。经过所有的努力,每次导入pylab时我仍然会收到此错误消息。请帮我?任何人吗?
$python
Python 2.7.4 (v2.7.4:026ee0057e2d, Apr 6 2013, 11:43:10)
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import pylab
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Library/Python/2.7/site-packages/matplotlib-1.1.0-py2.7-macosx-10.7-intel.egg/pylab.py", line 1, in <module>
from matplotlib.pylab import *
File "/Library/Python/2.7/site-packages/matplotlib-1.1.0-py2.7-macosx-10.7-intel.egg/matplotlib/pylab.py", line 221, in <module>
`from matplotlib import mpl # pulls in most modules
File "/Library/Python/2.7/site-packages/matplotlib-1.1.0-py2.7-macosx-10.7-intel.egg/matplotlib/mpl.py", line 2, in <module>
`from matplotlib import axis
File "/Library/Python/2.7/site-packages/matplotlib-1.1.0-py2.7-macosx-10.7-intel.egg/matplotlib/axis.py", line 14, in <module>
`import matplotlib.text as mtext
File "/Library/Python/2.7/site-packages/matplotlib-1.1.0-py2.7-macosx-10.7-intel.egg/matplotlib/text.py", line 31, in <module>
`from matplotlib.backend_bases import RendererBase
File "/Library/Python/2.7/site-packages/matplotlib-1.1.0-py2.7-macosx-10.7-intel.egg/matplotlib/backend_bases.py", line 48, in <module>
`import matplotlib.textpath as textpath
File "/Library/Python/2.7/site-packages/matplotlib-1.1.0-py2.7-macosx-10.7-intel.egg/matplotlib/textpath.py", line 9, in <module>
`from matplotlib.mathtext import MathTextParser
File "/Library/Python/2.7/site-packages/matplotlib-1.1.0-py2.7-macosx-10.7-intel.egg/matplotlib/mathtext.py", line 52, in <module>
`import matplotlib._png as _png
ImportError: dlopen(/Library/Python/2.7/site-packages/matplotlib-1.1.0-py2.7-macosx-10.7-intel.egg/matplotlib/_png.so, 2): Library not loaded: /opt/local/lib/libpng14.14.dylib
Referenced from: /Library/Python/2.7/site-packages/matplotlib-1.1.0-py2.7-macosx-10.7-intel.egg/matplotlib/_png.so
Reason: image not found
此外,我按照http://ipython.org/install.html上的说明安装了Anaconda。安装Anaconda后,我进入了下一步
$ conda update conda
并得到了这个
"-bash: conda: command not found"
我在网上搜索,但似乎没有人有这个问题。谁能在这里给我一个提示?非常感谢!
在我的目录/ usr / bin中我有
python python-config python2.5 python2.5-config python2.6 python2.6-config python2.7 python2.7-config
用命令 哪个python
我得到了/Library/Frameworks/Python.framework/Versions/2.7/bin/python
与 哪个ipython
我得到了/Library/Frameworks/Python.framework/Versions/2.7/bin/ipython
对于numpy,我下载了软件包numpy-1.7.0-py2.7-python.org-macosx10.6.dmg,scipy-0.12.0-py2.7-python.org-macosx10.6.dmg for scipy和matplotbib的matplotlib-1.2.0-py2.7-python.org-macosx10.6.dmg。我下载了* 10.6.dmg,因为这是我发现的......我找不到像* 10.7.dmg这样的东西
我没有.bashrc或.bashrc_profile。但我认为.profile会这样做,它就像这样读到
# MacPorts Installer addition on 2012-03-07_at_18:55:26: adding an appropriate PATH variable for use with MacPorts.
export PATH=/opt/local/bin:/opt/local/sbin:$PATH
# Finished adapting your PATH environment variable for use with MacPorts.
export TERM="xterm-color"
alias ls="ls -G"
export PS1="[\[\e[33m\]\u@\H \[\e[32m\]\w\[\e[0m\]]\n[\[\e[31m\]\!\[\e[0m\]] > "
# Setting PATH for Python 2.7
# The orginal version is saved in .profile.pysave
PATH="/Library/Frameworks/Python.framework/Versions/2.7/bin:${PATH}"
export PATH
当我输入
时$端口
它说-bash: port: command not found
这会让我担心吗?
我还要发表评论
export PATH=/opt/local/bin:/opt/local/sbin:$PATH
以及?
答案 0 :(得分:1)
您似乎拥有MacPorts。也许您可以使用MacPorts来安装您选择的Python,然后使用相应的pip
(可能/opt/local/bin/pip
来安装必要的Python包。
如果MacPorts不再使用,我建议改为使用自制程序:http://mxcl.github.io/homebrew/。注意安装Python后得到的消息:它告诉你一些Python脚本将安装在/usr/local/share/python
中。在您的情况下,这可能不是问题(您列出的软件包不会安装Python脚本)。
请记住,一起使用自制软件和MacPorts可能仍然会破坏Python及其软件包。
最后,您需要确保不继续使用其他python可执行文件。因此,在.profile
中,请注释掉最后两行:
#PATH="/Library/Frameworks/Python.framework/Versions/2.7/bin:${PATH}"
#export PATH
<强>更新强>
然后,要摆脱MacPorts参考并确保您的PATH选择/usr/local/bin
,请将.profile
进一步更改为
# MacPorts Installer addition on 2012-03-07_at_18:55:26: adding an appropriate PATH variable for use with MacPorts.
#export PATH=/opt/local/bin:/opt/local/sbin:$PATH # <- comment out
# Set /usr/local/bin explicitly for Homebrew
export PATH=/usr/local/bin:$PATH
从新的终端(或标签)开始,让您的设置更新。