2017-10-04 221 views
0

在Mac上,嘗試獲取Python 3.6安裝程序。Python無法找到與pip一起安裝的軟件包

Sams-MacBook-Pro:~ samgreenberg$ which pip3 
/Library/Frameworks/Python.framework/Versions/3.6/bin/pip3 
Sams-MacBook-Pro:~ samgreenberg$ which python3 
/Library/Frameworks/Python.framework/Versions/3.6/bin/python3 

然後

Sams-MacBook-Pro:~ samgreenberg$ pip3 list 
DEPRECATION: The default format will switch to columns in the future. 

You can use --format=(legacy|columns) (or define a format=(legacy|columns) in your pip.conf under the [list] section) to disable this warning. 
biopython (1.70) 
certifi (2017.7.27.1) 
chardet (3.0.4) 
cycler (0.10.0) 
decorator (4.1.2) 
idna (2.6) 
ipython-genutils (0.2.0) 
jsonschema (2.6.0) 
jupyter-core (4.3.0) 
matplotlib (2.0.2) 
nbformat (4.4.0) 
numpy (1.13.1) 
olefile (0.44) 
Pillow (4.3.0) 
pip (9.0.1) 
plotly (2.0.15) 
pyparsing (2.2.0) 
python-dateutil (2.6.1) 
pytz (2017.2) 
requests (2.18.4) 
setuptools (28.8.0) 
six (1.10.0) 
traitlets (4.3.2) 
urllib3 (1.22) 

所以biopython似乎安裝

Sams-MacBook-Pro:~ samgreenberg$ python3 -m pip install biopython 
Requirement already satisfied: biopython in /Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages 
Requirement already satisfied: numpy in /Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages (from biopython) 

肯定安裝。

Sams-MacBook-Pro:~ samgreenberg$ python3 
Python 3.6.2 (v3.6.2:5fd33b5926, Jul 16 2017, 20:11:06) 
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin 
Type "help", "copyright", "credits" or "license" for more information. 
>>> import urllib3 
>>> import biopython 
Traceback (most recent call last): 
    File "<stdin>", line 1, in <module> 
ModuleNotFoundError: No module named 'biopython' 
>>> 

urllib3工作,但不是新安裝的軟件包。使用pip卸載並重新安裝沒有效果,當我嘗試使用隨機的其他軟件包時,結果相同。我究竟做錯了什麼?我對Python或OSX沒有特別的經驗。我的電腦預裝了Python 2.7,但我很小心地在命令中使用Python3。

回答

2

當我們使用一些python模塊時,我們通常會寫>>> import module。例如,>>> import urllib3。但是,一些軟件包,包括biopython,不在這個規則之內。您嘗試鍵入>>> import Bio>>> print(Bio.__version__)。請在http://biopython.org/DIST/docs/tutorial/Tutorial.html查詢更多詳情。

--original answer--

請嘗試鍵入以下腳本:

>>import sys 
>>print(sys.path) 

我覺得有沒有/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages但只有python2的模塊路徑。

如果要解決這個問題暫時的,請使用以下命令:

>>sys.path.append("/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages") 

~/.bash_profile定義PYTHONPATH並重新啓動你的終端,如果你總是使用python3:

PYTHONPATH=/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages:$PYTHONPATH 

+0

>>> import sys >>> print(sys.path) ['','/Library/Frameworks/Python.framework/Versions/3.6/lib/ python36.zip', '/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6', '/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/lib- dynload', '/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site- packages'] – Sam

+0

我誤解了什麼是biopython。當我們使用一些python模塊時,我們通常會編寫'>>> import module'。例如,>>> import urllib3'。但是,一些軟件包,包括biopython,不在這個規則之內。您嘗試輸入>>> >>>導入Bio'和>>> print(Bio .__ version __)'。請查看[http://biopython.org/DIST/docs/tutorial/Tutorial.html](http://biopython.org/DIST/docs/tutorial/Tutorial.html)上的更多詳細信息。 – montblanc18

+0

非常感謝,我應該閱讀文檔。我嘗試使用Pillow作爲測試,結果沒有發現該軟件包也以不同的名稱導入。 – Sam

相關問題