Python Jupyter notebook 命令在 Mac 上不起作用

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/35029029/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-19 15:54:06  来源:igfitidea点击:

Jupyter notebook command does not work on Mac

pythonmacosjupyterjupyter-notebook

提问by pokiman

I installed jupyter using pip on my macbook air. Upon trying to execute the command jupyter notebook, I get an error

我在我的 macbook air 上使用 pip 安装了 jupyter。尝试执行命令时jupyter notebook,出现错误

jupyter: 'notebook' is not a Jupyter command

I used the --h option to get a listing of all jupyter commands and indeed, 'notebook' is not one of the commands. I am running python 2.7 and it was already installed before I installed jupyter.

我使用 --h 选项来获取所有 jupyter 命令的列表,实际上,“notebook”不是命令之一。我正在运行 python 2.7,并且在安装 jupyter 之前已经安装了它。

I searched on google and I see a similar problem some people have faced with the latest version of jupyter but I don't see any solutions. Can somebody point me in the right direction?

我在谷歌上搜索,我看到一些人在最新版本的 jupyter 中遇到了类似的问题,但我没有看到任何解决方案。有人可以指出我正确的方向吗?

which -a pip: /usr/local/bin/pip

which -a pip: /usr/local/bin/pip

which -a jupyter: /usr/local/bin/jupyter

which -a jupyter:/usr/local/bin/jupyter

回答by mic

I had the same problem. After looking to a gazillion of pages on line and trying as many solutions, this is the only thing that worked for me:

我有同样的问题。在网上查看了无数页面并尝试了尽可能多的解决方案之后,这是唯一对我有用的方法:

pip uninstall notebook
pip install --upgrade notebook

I am not sure that the "upgrade" is necessary, but after that I had

我不确定“升级”是否必要,但在那之后我有

jupyter-notebook

and

jupyter notebook

as commands.

作为命令。

回答by Léo Léopold Hertz ??

I got the same error as you when which jupyteris /usr/local/bin/jupyter. I managed to solve the case by updating/upgrading all my ipython packages

which jupyteris时,我遇到了和你一样的错误/usr/local/bin/jupyter。我设法通过更新/升级我所有的 ipython 包来解决这个问题

sudo -H pip install --upgrade "ipython[all]"

I managed to solve the case in OS X El-Capitan 10.11.5 and Ubuntu Linux 16.04. My Jupyter version after the upgrade is 4.1.0. My Python is 2.7.11+. My Pip version is 8.1.2.

我设法在 OS X El-Capitan 10.11.5 和 Ubuntu Linux 16.04 中解决了这个问题。我升级后的 Jupyter 版本是 4.1.0。我的 Python 是 2.7.11+。我的 Pip 版本是 8.1.2。

回答by cprakashagr

Try to find out the folder to which the binaries were installed using this command from the home folder:

尝试使用以下命令从主文件夹中找出安装二进制文件的文件夹:

find . -name "jupyter"

If you find any binary, execute it from that path directly or set that path to $PATH.

如果您找到任何二进制文件,请直接从该路径执行它或将该路径设置为$PATH.

回答by Danny Shau

use: sudo pip install notebookin terminal.

用途:sudo pip install notebook在终端。

回答by deepakpanth

I was getting error while installing jupyter on MacOS Sierra. Was struggling to install jupyter and later found the cause so sharing here.

在 MacOS Sierra 上安装 jupyter 时出现错误。正在努力安装 jupyter,后来找到了原因,所以在这里分享。

The exceptions were like below -

例外情况如下 -

Exception:
Traceback (most recent call last):
  File "/Library/Python/2.7/site-packages/pip/basecommand.py", line 215, in main
    status = self.run(options, args)
  File "/Library/Python/2.7/site-packages/pip/commands/install.py", line 342, in run
    prefix=options.prefix_path,
  File "/Library/Python/2.7/site-packages/pip/req/req_set.py", line 778, in install
    requirement.uninstall(auto_confirm=True)
  File "/Library/Python/2.7/site-packages/pip/req/req_install.py", line 754, in uninstall
    paths_to_remove.remove(auto_confirm)
  File "/Library/Python/2.7/site-packages/pip/req/req_uninstall.py", line 115, in remove
    renames(path, new_path)
  File "/Library/Python/2.7/site-packages/pip/utils/__init__.py", line 267, in renames
    shutil.move(old, new)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 299, in move
    copytree(src, real_dst, symlinks=True)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 208, in copytree
    raise Error, errors
Error: [('/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/dateutil/__init__.py', '/tmp/pip-tchevt-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/dateutil/__init__.py', "[Errno 1] Operation not permitted: '/tmp/pip-tchevt-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/dateutil/__init__.py'"), ('/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/dateutil/__init__.pyc', '/tmp/pip-tchevt-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/dateutil/__init__.pyc', "[Errno 1] Operation not permitted: '/tmp/pip-tchevt-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/dateutil/__init__.pyc'"), ('/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/dateutil/easter.py', '/tmp/pip-tchevt-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/dateutil/easter.py', "[Errno 1] Operation not permitted: '/tmp/pip-tchevt-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/dateutil/easter.py'"), ('/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/dateutil/easter.pyc', '/tmp/pip-tchevt-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/dateutil/easter.pyc', "[Errno 1] Operation not permitted: '/tmp/pip-tchevt-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/dateutil/easter.pyc'"), ('/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/dateutil/parser.py', '/tmp/pip-tchevt-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/dateutil/parser.py', "[Errno 1] Operation not permitted: '/tmp/pip-tchevt-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/dateutil/parser.py'"), ('/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/dateutil/parser.pyc', '/tmp/pip-tchevt-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/dateutil/parser.pyc', "[Errno 1] Operation not permitted: '/tmp/pip-tchevt-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/dateutil/parser.pyc'"), ('/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/dateutil/relativedelta.py', '/tmp/pip-tchevt-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/dateutil/relativedelta.py', "[Errno 1] Operation not permitted: '/tmp/pip-tchevt-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/dateutil/relativedelta.py'"), ('/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/dateutil/relativedelta.pyc', '/tmp/pip-tchevt-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/dateutil/relativedelta.pyc', "[Errno 1] Operation not permitted: '/tmp/pip-tchevt-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/dateutil/relativedelta.pyc'"), ('/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/dateutil/rrule.py', '/tmp/pip-tchevt-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/dateutil/rrule.py', "[Errno 1] Operation not permitted: '/tmp/pip-tchevt-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/dateutil/rrule.py'"), ('/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/dateutil/rrule.pyc', '/tmp/pip-tchevt-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/dateutil/rrule.pyc', "[Errno 1] Operation not permitted: '/tmp/pip-tchevt-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/dateutil/rrule.pyc'"), ('/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/dateutil/tz.py', '/tmp/pip-tchevt-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/dateutil/tz.py', "[Errno 1] Operation not permitted: '/tmp/pip-tchevt-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/dateutil/tz.py'"), ('/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/dateutil/tz.pyc', '/tmp/pip-tchevt-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/dateutil/tz.pyc', "[Errno 1] Operation not permitted: '/tmp/pip-tchevt-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/dateutil/tz.pyc'"), ('/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/dateutil/tzwin.py', '/tmp/pip-tchevt-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/dateutil/tzwin.py', "[Errno 1] Operation not permitted: '/tmp/pip-tchevt-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/dateutil/tzwin.py'"), ('/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/dateutil/tzwin.pyc', '/tmp/pip-tchevt-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/dateutil/tzwin.pyc', "[Errno 1] Operation not permitted: '/tmp/pip-tchevt-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/dateutil/tzwin.pyc'"), ('/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/dateutil/zoneinfo/__init__.py', '/tmp/pip-tchevt-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/dateutil/zoneinfo/__init__.py', "[Errno 1] Operation not permitted: '/tmp/pip-tchevt-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/dateutil/zoneinfo/__init__.py'"), ('/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/dateutil/zoneinfo/__init__.pyc', '/tmp/pip-tchevt-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/dateutil/zoneinfo/__init__.pyc', "[Errno 1] Operation not permitted: '/tmp/pip-tchevt-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/dateutil/zoneinfo/__init__.pyc'"), ('/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/dateutil/zoneinfo/zoneinfo-2010g.tar.gz', '/tmp/pip-tchevt-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/dateutil/zoneinfo/zoneinfo-2010g.tar.gz', "[Errno 1] Operation not permitted: '/tmp/pip-tchevt-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/dateutil/zoneinfo/zoneinfo-2010g.tar.gz'"), ('/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/dateutil/zoneinfo', '/tmp/pip-tchevt-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/dateutil/zoneinfo', "[Errno 1] Operation not permitted: '/tmp/pip-tchevt-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/dateutil/zoneinfo'"), ('/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/dateutil', '/tmp/pip-tchevt-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/dateutil', "[Errno 1] Operation not permitted: '/tmp/pip-tchevt-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/dateutil'")]

I found this issue in MacOS Sierra and El-Capitan and fixed this by ignoring six.

我在 MacOS Sierra 和 El-Capitan 中发现了这个问题,并通过忽略六个来解决这个问题。

pip install --upgrade notebook --ignore-installed six

Ref - https://github.com/pypa/pip/issues/3165

参考 - https://github.com/pypa/pip/issues/3165

回答by Zero

I find one solution which solved this problem on my Mac

我找到了一个解决方案在我的 Mac 上解决了这个问题

sudo rm -rf /Library/Frameworks/Python.framework
rm /usr/local/bin/python3*
brew uninstall python3
brew install python3
which python3
sudo python3 -m pip install --upgrade pip
sudo python3 -m pip install jupyter
which jupyter
jupyter notebook

回答by Mr. Demetrius Michael

Seems like Apple wants things out of the "Systems" folder as much as possible. This is so you can keep viruses local to your "user", rather than your entire computer.

似乎苹果希望尽可能多地从“系统”文件夹中删除内容。这样您就可以将病毒保留在您的“用户”本地,而不是您的整个计算机。

So if you have a "user" installed Python and Jupyter, then you will need to just make sure they're found before you try running it.

因此,如果您有一个安装了 Python 和 Jupyter 的“用户”,那么您只需确保在尝试运行它之前找到了它们。

If you have that problem, and this folder exists ~/Library/Python/2.7/binthen do below:

如果您遇到该问题,并且此文件夹存在,~/Library/Python/2.7/bin请执行以下操作:

  1. Add your user to your path $ echo 'export PATH="$HOME/Library/Python/2.7/bin:${PATH}"' >> ~/.bash_profile

  2. Reload your Bash profile $ . ~/.bash_profile

  3. Install Jupiter with user permissions $ python -m pip install jupyter --user

  1. 将您的用户添加到您的路径中 $ echo 'export PATH="$HOME/Library/Python/2.7/bin:${PATH}"' >> ~/.bash_profile

  2. 重新加载您的 Bash 配置文件 $ . ~/.bash_profile

  3. 使用用户权限安装 Jupiter $ python -m pip install jupyter --user

回答by Jay Patel

Uninstalling python3 and jupyter and installing them using HomeBrew worked for me.

卸载 python3 和 jupyter 并使用 HomeBrew 安装它们对我有用。

pip3 uninstall python3
pip3 uninstall jupyter
brew install python3
brew install jupyter
which jupyter
jupyter notebook

Worked for me on macOS Catalina

在 macOS Catalina 上为我工作