我試了很長時間才能在Mac上使用python。我試圖從我的mac中完全刪除python。然後我意識到很難擺脫這個默認的Python。幸運的是,我在互聯網上讀到,在我想出如何刪除它之前,刪除Mac中隨附的一個python是個壞主意。然後,我還使用* .dmg包安裝了python,numpy,scipy,matplotlib。經過所有的努力,我每次導入pylab時仍然會收到此錯誤消息。請幫幫我?任何人?如何在Mac 10.7.5上正確安裝matplotlib?爲什麼Anaconda安裝成功後找不到命令「conda」?
$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。安裝後,蟒蛇我去到下一個步驟
$ 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
隨着命令 我/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爲SciPy,matplotlib-1.2.0-py2.7-python.org-macosx10.6.dmg爲matplotbib.I下載* 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\]\[email protected]\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
呢?
你是如何安裝東西的?你安裝了二進制文件嗎?來自哪裏? 10.7在'/ usr/bin/python'中默認使用Python,但我認爲這是2.7.1版本。 – Evert 2013-05-07 08:33:12
這幾天,我會推薦嘗試[Homebrew](http://mxcl.github.io/homebrew/)。但是,我還建議刪除剛纔安裝的所有東西(詢問是否需要更多信息),然後再開始衝突。然後,在安裝python後,你必須調整一下'PATH'並使用'pip'來安裝所有其他軟件包(ipython,mpl,numpy等)。 – Evert 2013-05-07 08:37:21
你在10.7.5上,你安裝了10.6個dmg文件?爲什麼?它可能有用,但它可能會導致不兼容。 – Evert 2013-05-07 09:41:05