2015-10-05 74 views
1

我最近更新到OSX El Capitain升級exhisting工作osx安裝。現在我有一個模塊,通過pip安裝在anaconda發行版上,現在已經損壞。或者更好的模塊可以從蟒蛇ipython無法加載python模塊

Python 2.7.10 |Anaconda 2.3.0 (x86_64)| (default, Sep 15 2015, 14:29:08) 
[GCC 4.2.1 (Apple Inc. build 5577)] on darwin 
Type "help", "copyright", "credits" or "license" for more information. 
Anaconda is brought to you by Continuum Analytics. 
Please check out: http://continuum.io/thanks and https://anaconda.org 
>>> import MDSplus as mds 

正確導入,而不會在IPython中加載,聲稱不找到一個圖書館。

Python 2.7.10 |Anaconda 2.3.0 (x86_64)| (default, Sep 15 2015, 14:29:08) 
Type "copyright", "credits" or "license" for more information. 

IPython 4.0.0 -- An enhanced Interactive Python. 
?   -> Introduction and overview of IPython's features. 
%quickref -> Quick reference. 
help  -> Python's own help system. 
object? -> Details about 'object', use 'object??' for extra details. 
Using matplotlib backend: MacOSX 

In [1]: import MDSplus as mds 
Error importing MDSplus package: Error finding library: MdsShr 

該庫已正確安裝,它在/ etc/profile文件中列出,它位於/ usr /本地(所以不應該有與OSX EL船長的新的安全系統出現問題)和python解釋了通過python或ipython調用的是相同的(Anaconda 2.3.0)。 我該如何診斷哪個是問題?

編輯: 在https://groups.google.com/a/continuum.io/forum/#!topic/anaconda/PEuOKEM5fdc建議的解決方案不適合我。它似乎沒有成爲一個環境問題,並命令

echo $DYLD_LIBRARY_PATH 

指向正確的路徑

編輯:

which -a ipython 
ipython is /Users/vianello/anaconda/bin/ipython 
which -a python 
python is /Users/vianello/anaconda/bin/python 
python is /usr/bin/python 

>>> import sys 
>>> for x in sys.path: print x 
>>>/Users/vianello/anaconda/lib/python2.7/site-packages/pyhht-0.0.1-py2.7.egg 
>>>/Users/vianello/anaconda/lib/python2.7/site-packages/MitDevices-0.3-py2.7.egg 
>>>/Users/vianello/anaconda/lib/python2.7/site-packages/MDSplus-alpha_7.0.157-py2.7.egg 
>>>//anaconda/lib/python2.7/site-packages/MDSplus-alpha_7.0.147-py2.7.egg/MDSplus 
>>>/Users/vianello/anaconda/lib/python27.zip 
>>>/Users/vianello/anaconda/lib/python2.7 
>>>/Users/vianello/anaconda/lib/python2.7/plat-darwin 
>>>/Users/vianello/anaconda/lib/python2.7/plat-mac 
>>>/Users/vianello/anaconda/lib/python2.7/plat-mac/lib-scriptpackages 
>>>/Users/vianello/anaconda/lib/python2.7/lib-tk 
>>>/Users/vianello/anaconda/lib/python2.7/lib-old 
>>>/Users/vianello/anaconda/lib/python2.7/lib-dynload 
>>>/Users/vianello/anaconda/lib/python2.7/site-packages 
>>>/Users/vianello/anaconda/lib/python2.7/site-packages/PIL 
>>>/Users/vianello/anaconda/lib/python2.7/site-packages/Sphinx-1.3.1-py2.7.egg 
>>>/Users/vianello/anaconda/lib/python2.7/site-packages/aeosa 
>>>/Users/vianello/anaconda/lib/python2.7/site-packages/lmfit-0.8.3-py2.7.egg 
>>>/Users/vianello/anaconda/lib/python2.7/site-packages/setuptools-18.3.2-py2.7.egg 
>>>/Users/vianello/anaconda/lib/python2.7/site-packages/suds-0.4-py2.7.egg 

在IPython中同樣給出結果

/Users/vianello/anaconda/bin 
/Users/vianello/anaconda/lib/python2.7/site-packages/pyhht-0.0.1-py2.7.egg 
/Users/vianello/anaconda/lib/python2.7/site-packages/MitDevices-0.3-py2.7.egg 
/Users/vianello/anaconda/lib/python2.7/site-packages/MDSplus-alpha_7.0.157-py2.7.egg 
/Users/vianello/anaconda/lib/python27.zip 
/Users/vianello/anaconda/lib/python2.7 
/Users/vianello/anaconda/lib/python2.7/plat-darwin 
/Users/vianello/anaconda/lib/python2.7/plat-mac 
/Users/vianello/anaconda/lib/python2.7/plat-mac/lib-scriptpackages 
/Users/vianello/anaconda/lib/python2.7/lib-tk 
/Users/vianello/anaconda/lib/python2.7/lib-old 
/Users/vianello/anaconda/lib/python2.7/lib-dynload 
/Users/vianello/anaconda/lib/python2.7/site-packages/Sphinx-1.3.1-py2.7.egg 
/Users/vianello/anaconda/lib/python2.7/site-packages/lmfit-0.8.3-py2.7.egg 
/Users/vianello/anaconda/lib/python2.7/site-packages/setuptools-18.3.2-py2.7.egg 
/Users/vianello/anaconda/lib/python2.7/site-packages/suds-0.4-py2.7.egg 
/Users/vianello/anaconda/lib/python2.7/site-packages 
/Users/vianello/anaconda/lib/python2.7/site-packages/PIL 
/Users/vianello/anaconda/lib/python2.7/site-packages/aeosa 
/Users/vianello/anaconda/lib/python2.7/site-packages/IPython/extensions 
/Users/vianello/.ipython 

因此MDSplus-alpha_7.0.157-py2.7.egg可以從Python和ipython

+0

寫在Python和庫路徑的報告是我沒有和提出的解決方案沒有解決的問題,即增加了PYTHONPATH沒有解決您的權利,我有問題 –

+0

編輯問題抱歉 –

+0

您是否正在從virtualenv運行ipython? –

回答

1

我的第一個想法是,您正與新的Apple系統完整性保護髮生衝突。 iPython使用通過/bin/bash加載的shell腳本啓動。這會導致你的DYLD_LIBRARY_PATH環境變量在python啓動時被剝離。您可以通過導入os然後嘗試打印os.environ["DYLD_LIBRARY_PATH"]的內容來檢查。如果該打印引發異常,那麼你知道問題是什麼。

對我而言,一個簡單的修復方法是編輯ipython腳本的第一行,以便#!直接調用您的python二進制文件,而不是通過bash進行。這不是一個長期的解決方案,因爲每次更新ipython直到上游更改(公平地說,我不確定爲什麼涉及bash)時都必須重做。

我在http://dmtn-001.lsst.io