2013-05-07 93 views
1

我試了很長時間才能在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

呢?

+0

你是如何安裝東西的?你安裝了二進制文件嗎?來自哪裏? 10.7在'/ usr/bin/python'中默認使用Python,但我認爲這是2.7.1版本。 – Evert 2013-05-07 08:33:12

+0

這幾天,我會推薦嘗試[Homebrew](http://mxcl.github.io/homebrew/)。但是,我還建議刪除剛纔安裝的所有東西(詢問是否需要更多信息),然後再開始衝突。然後,在安裝python後,你必須調整一下'PATH'並使用'pip'來安裝所有其他軟件包(ipython,mpl,numpy等)。 – Evert 2013-05-07 08:37:21

+0

你在10.7.5上,你安裝了10.6個dmg文件?爲什麼?它可能有用,但它可能會導致不兼容。 – Evert 2013-05-07 09:41:05

回答

1

您似乎有MacPorts。也許你可以使用MacPorts的安裝你所選擇的Python中,然後用相應的pip(可能/opt/local/bin/pip安裝必要的Python包。

如果MacPorts的是你不再使用的東西,我建議使用自制軟件,而不是:http://mxcl.github.io/homebrew/。注意安裝Python後得到的消息:它告訴你一些Python腳本將被安裝在/usr/local/share/python中。在你的情況下,這可能不是問題(你列出的包不安裝Python腳本afaik)。

請記住,一起使用自制軟件和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 

從新終端(或標籤)開始更新設置。

+0

這對我所有搞砸的mac都很棘手。但是!導入pylab後沒有錯誤信息!謝謝! – blur 2013-05-07 14:17:14

相關問題