在Mac上正確使用Python似乎是一個持續的挑戰。我有一個自制的實施工作,現在有困難運行Jupyter除了使用sudo:在Mac上修復Python
$ which python
/usr/local/bin/python
$ which pip
/Users/username/bin/pip
$ which jupyter
/usr/local/bin/jupyter
$ jupyter notebook
Traceback (most recent call last):
File "/usr/local/bin/jupyter", line 7, in <module>
from jupyter_core.command import main
ImportError: No module named jupyter_core.command
$ sudo jupyter notebook
The Jupyter Notebook is running at: http://localhost:8888/
運行後,Jupyter無法導入大熊貓(通過pip install pandas
安裝):
import pandas
ImportError Traceback (most recent call last)
<ipython-input-18-d6ac987968b6> in <module>()
----> 1 import pandas
ImportError: No module named pandas
..甚至雖然熊貓可用(python -s 'import pandas'
工作正常)。猜測它的路徑不可用於root。
我想知道Jupyter是particularly problematic或者這只是我的設置..?
感謝您的幫助,因爲這變得非常煩人。任何有關擦除python並從頭重新安裝「正確」的指導都會很方便。
編輯:
$ which virtualenv
/usr/local/bin/virtualenv
21:16 $ virtualenv
Traceback (most recent call last):
File "/usr/local/bin/virtualenv", line 7, in <module>
from virtualenv import main
ImportError: No module named virtualenv
謝謝Ray。試過在上面安裝virtualenv和命中錯誤。任何想法? – geotheory
@geotheory如果你在python3中,不要使用'virtualenv',使用'pyvenv'它可以做同樣的事情。 https://docs.python.org/3/library/venv.html – Ray
這是否適用於Mac上的Python 2.7? 'pip安裝pyvenv'返回'找不到滿足要求的版本pyvenv(來自版本:)沒有找到與pyvenv匹配的發佈... – geotheory