Mac下Jupyter(Ipython)的安装与使用

快速开始

正常安装的是:

sudo pip install jupyter 

但这样安装在Mac下面会遇到各种各样的问题,可以试试下面的安装。

pip install --ignore-installed --user jupyter

然后

jupyter notebook

应该就可以正常运行啦。

注意,不要在前面加sudo,不要加sudo,sudo,加了安装成功后在后面jupyter notebook会提示jupyter: 'notebook' is not a Jupyter command mac 等错误。

如果不行,可使用pip3来安装可正常使用。

sudo pip3 install jupyter --ignore-installed

以下是安装过程中遇到的错误。

Uninstalling six-1.4.1:
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 "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 302, in move
    copy2(src, real_dst)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 131, in copy2
    copystat(src, dst)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 103, in copystat
    os.chflags(dst, st.st_flags)
OSError: [Errno 1] Operation not permitted: '/tmp/pip-vfVdGf-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/six-1.4.1-py2.7.egg-info'

进入Python命令行模式import six是正常的,看样子是卸载1.4.1版本的时候出现了错误,网上搜索找到了解决办法,直接ignore安装six.

sudo pip install jupyter --upgrade --ignore-installed six

然后没提示错误了,然后错误又来了

  Running setup.py install for scandir ... done
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 784, in install
    **kwargs
  File "/Library/Python/2.7/site-packages/pip/req/req_install.py", line 851, in install
    self.move_wheel_files(self.source_dir, root=root, prefix=prefix)
  File "/Library/Python/2.7/site-packages/pip/req/req_install.py", line 1064, in move_wheel_files
    isolated=self.isolated,
  File "/Library/Python/2.7/site-packages/pip/wheel.py", line 377, in move_wheel_files
    clobber(source, dest, False, fixer=fixer, filter=filter)
  File "/Library/Python/2.7/site-packages/pip/wheel.py", line 316, in clobber
    ensure_dir(destdir)
  File "/Library/Python/2.7/site-packages/pip/utils/__init__.py", line 83, in ensure_dir
    os.makedirs(path)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/os.py", line 150, in makedirs
    makedirs(head, mode)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/os.py", line 150, in makedirs
    makedirs(head, mode)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/os.py", line 157, in makedirs
    mkdir(name, mode)
OSError: [Errno 1] Operation not permitted: '/System/Library/Frameworks/Python.framework/Versions/2.7/share'

报此错误,然后添加--user后终于可以正常安装好。

sudo -H  pip install jupyter --user  --upgrade --ignore-installed six

然后安装成功。

Installing collected packages: MarkupSafe, jinja2, pygments, mistune, enum34, six, decorator, ipython-genutils, traitlets, jupyter-core, functools32, jsonschema, nbformat, configparser, entrypoints, pandocfilters, testpath, html5lib, bleach, nbconvert, simplegeneric, ptyprocess, pexpect, backports.shutil-get-terminal-size, wcwidth, prompt-toolkit, appdirs, pyparsing, packaging, setuptools, scandir, pathlib2, pickleshare, appnope, ipython, singledispatch, certifi, backports-abc, tornado, pyzmq, jupyter-client, ipykernel, terminado, notebook, jupyter-console, widgetsnbextension, ipywidgets, qtconsole, jupyter
  Running setup.py install for MarkupSafe ... done
  Running setup.py install for functools32 ... done
  Running setup.py install for configparser ... done
  Running setup.py install for pandocfilters ... done
  Running setup.py install for html5lib ... done
  Running setup.py install for simplegeneric ... done
  Running setup.py install for scandir ... done
  Running setup.py install for tornado ... done
  Running setup.py install for terminado ... done
Successfully installed MarkupSafe-0.23 appdirs-1.4.0 appnope-0.1.0 backports-abc-0.5 backports.shutil-get-terminal-size-1.0.0 bleach-1.5.0 certifi-2017.1.23 configparser-3.5.0 decorator-4.0.11 entrypoints-0.2.2 enum34-1.1.6 functools32-3.2.3.post2 html5lib-0.9999999 ipykernel-4.5.2 ipython-5.1.0 ipython-genutils-0.1.0 ipywidgets-5.2.2 jinja2-2.9.4 jsonschema-2.5.1 jupyter-1.0.0 jupyter-client-4.4.0 jupyter-console-5.0.0 jupyter-core-4.2.1 mistune-0.7.3 nbconvert-5.1.1 nbformat-4.2.0 notebook-4.3.1 packaging-16.8 pandocfilters-1.4.1 pathlib2-2.2.1 pexpect-4.2.1 pickleshare-0.7.4 prompt-toolkit-1.0.9 ptyprocess-0.5.1 pygments-2.2.0 pyparsing-2.1.10 pyzmq-16.0.2 qtconsole-4.2.1 scandir-1.4 setuptools-34.0.1 simplegeneric-0.8.1 singledispatch-3.4.0.3 six-1.10.0 terminado-0.6 testpath-0.3 tornado-4.4.2 traitlets-4.3.1 wcwidth-0.1.7 widgetsnbextension-1.2.6

然后高兴的运行

jupyter notebook

啦呢~~ 提示

jupyter: 'notebook' is not a Jupyter command mac

然后在搜索测试,发现安装的时候不加sudo居然就可以运行了。

参考连接

  1. http://stackoverflow.com/questions/33004708/osx-el-capitan-sudo-pip-install-oserror-errno-1-operation-not-permitted

  2. https://github.com/pypa/pip/issues/3165


相关推荐


评论(0条)

暂时还没有评论,第一个来评论吧!


我要发表看法

引用   粗体   链接   缩进  

最近编辑

热门标签