簡體   English   中英

無法直接在 Mac 上的終端中運行 Jupyter notebook

[英]Cannot run Jupyter notebook directly in the terminal on Mac

我想在終端中使用jupyter notebook在我的 mac 上運行 jupyter notebook,但是如果我運行這段代碼,它會給我一個錯誤:

vlan-2625-10-16-106-253:~ brandon$ jupyter notebook
Traceback (most recent call last):
  File "/usr/local/bin/jupyter-notebook", line 5, in <module>
    from notebook.notebookapp import main
ModuleNotFoundError: No module named 'notebook'

但是如果我使用/usr/local/bin/python3.7 -m jupyter notebook ,那么它可以工作。

我知道可能是因為我的電腦上有幾個版本的python,或者是因為jupyter的路徑不正確,但我不知道如何處理。

vlan-2625-10-16-106-253:~ brandon$ which jupyter
/usr/local/bin/jupyter
vlan-2625-10-16-106-253:~ brandon$ which python3
/usr/local/bin/python3

如果我嘗試通過brew uninstall jupyterpip3 uninstall jupyter然后pip3 install jupyter ,它仍然無法正常工作。

如果我再次安裝 jupyter,它會顯示:

vlan-2625-10-16-106-253:~ brandon$ pip3 install jupyter
Defaulting to user installation because normal site-packages is not writeable
Requirement already satisfied: jupyter in /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages (1.0.0)
Requirement already satisfied: notebook in ./Library/Python/3.7/lib/python/site-packages (from jupyter) (6.3.0)
Requirement already satisfied: nbconvert in ./Library/Python/3.7/lib/python/site-packages (from jupyter) (5.6.1)
Requirement already satisfied: qtconsole in ./Library/Python/3.7/lib/python/site-packages (from jupyter) (4.7.6)
Requirement already satisfied: ipykernel in ./Library/Python/3.7/lib/python/site-packages (from jupyter) (5.3.4)
Requirement already satisfied: jupyter-console in ./Library/Python/3.7/lib/python/site-packages (from jupyter) (6.2.0)
Requirement already satisfied: ipywidgets in ./Library/Python/3.7/lib/python/site-packages (from jupyter) (7.5.1)
Requirement already satisfied: jupyter-client in ./Library/Python/3.7/lib/python/site-packages (from ipykernel->jupyter) (6.1.7)
Requirement already satisfied: traitlets>=4.1.0 in ./Library/Python/3.7/lib/python/site-packages (from ipykernel->jupyter) (5.0.0)
Requirement already satisfied: ipython>=5.0.0 in ./Library/Python/3.7/lib/python/site-packages (from ipykernel->jupyter) (7.18.1)
Requirement already satisfied: appnope in ./Library/Python/3.7/lib/python/site-packages (from ipykernel->jupyter) (0.1.0)
Requirement already satisfied: tornado>=4.2 in ./Library/Python/3.7/lib/python/site-packages (from ipykernel->jupyter) (6.1)
Requirement already satisfied: pexpect>4.3 in ./Library/Python/3.7/lib/python/site-packages (from ipython>=5.0.0->ipykernel->jupyter) (4.8.0)
Requirement already satisfied: prompt-toolkit!=3.0.0,!=3.0.1,<3.1.0,>=2.0.0 in ./Library/Python/3.7/lib/python/site-packages (from ipython>=5.0.0->ipykernel->jupyter) (3.0.7)
Requirement already satisfied: backcall in ./Library/Python/3.7/lib/python/site-packages (from ipython>=5.0.0->ipykernel->jupyter) (0.2.0)
Requirement already satisfied: pickleshare in ./Library/Python/3.7/lib/python/site-packages (from ipython>=5.0.0->ipykernel->jupyter) (0.7.5)
Requirement already satisfied: setuptools>=18.5 in ./Library/Python/3.7/lib/python/site-packages (from ipython>=5.0.0->ipykernel->jupyter) (49.2.0)
Requirement already satisfied: jedi>=0.10 in ./Library/Python/3.7/lib/python/site-packages (from ipython>=5.0.0->ipykernel->jupyter) (0.17.2)
Requirement already satisfied: decorator in ./Library/Python/3.7/lib/python/site-packages (from ipython>=5.0.0->ipykernel->jupyter) (4.4.2)
Requirement already satisfied: pygments in ./Library/Python/3.7/lib/python/site-packages (from ipython>=5.0.0->ipykernel->jupyter) (2.6.1)
Requirement already satisfied: parso<0.8.0,>=0.7.0 in ./Library/Python/3.7/lib/python/site-packages (from jedi>=0.10->ipython>=5.0.0->ipykernel->jupyter) (0.7.1)
Requirement already satisfied: ptyprocess>=0.5 in ./Library/Python/3.7/lib/python/site-packages (from pexpect>4.3->ipython>=5.0.0->ipykernel->jupyter) (0.6.0)
Requirement already satisfied: wcwidth in ./Library/Python/3.7/lib/python/site-packages (from prompt-toolkit!=3.0.0,!=3.0.1,<3.1.0,>=2.0.0->ipython>=5.0.0->ipykernel->jupyter) (0.2.5)
Requirement already satisfied: ipython-genutils in ./Library/Python/3.7/lib/python/site-packages (from traitlets>=4.1.0->ipykernel->jupyter) (0.2.0)
Requirement already satisfied: widgetsnbextension~=3.5.0 in ./Library/Python/3.7/lib/python/site-packages (from ipywidgets->jupyter) (3.5.1)
Requirement already satisfied: nbformat>=4.2.0 in ./Library/Python/3.7/lib/python/site-packages (from ipywidgets->jupyter) (5.0.7)
Requirement already satisfied: jupyter-core in /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages (from nbformat>=4.2.0->ipywidgets->jupyter) (4.7.1)
Requirement already satisfied: jsonschema!=2.5.0,>=2.4 in ./Library/Python/3.7/lib/python/site-packages (from nbformat>=4.2.0->ipywidgets->jupyter) (3.2.0)
Requirement already satisfied: pyrsistent>=0.14.0 in ./Library/Python/3.7/lib/python/site-packages (from jsonschema!=2.5.0,>=2.4->nbformat>=4.2.0->ipywidgets->jupyter) (0.16.0)
Requirement already satisfied: six>=1.11.0 in ./Library/Python/3.7/lib/python/site-packages (from jsonschema!=2.5.0,>=2.4->nbformat>=4.2.0->ipywidgets->jupyter) (1.15.0)
Requirement already satisfied: attrs>=17.4.0 in ./Library/Python/3.7/lib/python/site-packages (from jsonschema!=2.5.0,>=2.4->nbformat>=4.2.0->ipywidgets->jupyter) (20.1.0)
Requirement already satisfied: importlib-metadata in ./Library/Python/3.7/lib/python/site-packages (from jsonschema!=2.5.0,>=2.4->nbformat>=4.2.0->ipywidgets->jupyter) (1.7.0)
Requirement already satisfied: terminado>=0.8.3 in ./Library/Python/3.7/lib/python/site-packages (from notebook->jupyter) (0.8.3)
Requirement already satisfied: Send2Trash>=1.5.0 in ./Library/Python/3.7/lib/python/site-packages (from notebook->jupyter) (1.5.0)
Requirement already satisfied: jinja2 in ./Library/Python/3.7/lib/python/site-packages (from notebook->jupyter) (2.11.2)
Requirement already satisfied: pyzmq>=17 in ./Library/Python/3.7/lib/python/site-packages (from notebook->jupyter) (22.0.3)
Requirement already satisfied: prometheus-client in ./Library/Python/3.7/lib/python/site-packages (from notebook->jupyter) (0.8.0)
Requirement already satisfied: argon2-cffi in ./Library/Python/3.7/lib/python/site-packages (from notebook->jupyter) (20.1.0)
Requirement already satisfied: python-dateutil>=2.1 in ./Library/Python/3.7/lib/python/site-packages (from jupyter-client->ipykernel->jupyter) (2.8.1)
Requirement already satisfied: cffi>=1.0.0 in ./Library/Python/3.7/lib/python/site-packages (from argon2-cffi->notebook->jupyter) (1.14.2)
Requirement already satisfied: pycparser in ./Library/Python/3.7/lib/python/site-packages (from cffi>=1.0.0->argon2-cffi->notebook->jupyter) (2.20)
Requirement already satisfied: zipp>=0.5 in ./Library/Python/3.7/lib/python/site-packages (from importlib-metadata->jsonschema!=2.5.0,>=2.4->nbformat>=4.2.0->ipywidgets->jupyter) (3.1.0)
Requirement already satisfied: MarkupSafe>=0.23 in ./Library/Python/3.7/lib/python/site-packages (from jinja2->notebook->jupyter) (1.1.1)
Requirement already satisfied: entrypoints>=0.2.2 in ./Library/Python/3.7/lib/python/site-packages (from nbconvert->jupyter) (0.3)
Requirement already satisfied: mistune<2,>=0.8.1 in ./Library/Python/3.7/lib/python/site-packages (from nbconvert->jupyter) (0.8.4)
Requirement already satisfied: pandocfilters>=1.4.1 in ./Library/Python/3.7/lib/python/site-packages (from nbconvert->jupyter) (1.4.2)
Requirement already satisfied: testpath in ./Library/Python/3.7/lib/python/site-packages (from nbconvert->jupyter) (0.4.4)
Requirement already satisfied: defusedxml in ./Library/Python/3.7/lib/python/site-packages (from nbconvert->jupyter) (0.6.0)
Requirement already satisfied: bleach in ./Library/Python/3.7/lib/python/site-packages (from nbconvert->jupyter) (3.1.5)
Requirement already satisfied: packaging in ./Library/Python/3.7/lib/python/site-packages (from bleach->nbconvert->jupyter) (20.4)
Requirement already satisfied: webencodings in ./Library/Python/3.7/lib/python/site-packages (from bleach->nbconvert->jupyter) (0.5.1)
Requirement already satisfied: pyparsing>=2.0.2 in ./Library/Python/3.7/lib/python/site-packages (from packaging->bleach->nbconvert->jupyter) (2.4.7)
Requirement already satisfied: qtpy in ./Library/Python/3.7/lib/python/site-packages (from qtconsole->jupyter) (1.9.0)

如果我想在 pyCharm 中運行.ipynb 文件,我也會收到同樣的錯誤: 在此處輸入圖像描述

我認為這是同樣的問題,因為我無法在終端中直接運行jupyter notebook 這個問題一直困擾着我很多,我搜索了很多,但我仍然無法弄清楚。 我想知道我是否可以更改jupyter命令的路徑? 如果有人能回答這個問題會很有幫助。

提前致謝!

您可以檢查 python.exe 是否已添加到 path.Environment Variables >>> System variables >>> path.(這是用於 Windows)但我認為應該有類似的東西。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM