IPython Notebook安装及使用

IPython Notebook安装及使用

在做吴恩达deeplearning作业的时候,发现需要用到ipython,在使用的过程中遇到以下错误:

*****@Mac:~$ ipython
Traceback (most recent call last):
  File "/usr/local/bin/ipython", line 9, in <module>
    load_entry_point('ipython==5.3.0', 'console_scripts', 'ipython')()
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources/__init__.py", line 565, in load_entry_point
    return get_distribution(dist).load_entry_point(group, name)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources/__init__.py", line 2697, in load_entry_point
    return ep.load()
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources/__init__.py", line 2370, in load
    return self.resolve()
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources/__init__.py", line 2376, in resolve
    module = __import__(self.module_name, fromlist=['__name__'], level=0)
  File "/Library/Python/2.7/site-packages/ipython-5.3.0-py2.7.egg/IPython/__init__.py", line 49, in <module>
    from .terminal.embed import embed
  File "/Library/Python/2.7/site-packages/ipython-5.3.0-py2.7.egg/IPython/terminal/embed.py", line 15, in <module>
    from IPython.core import magic_arguments
  File "/Library/Python/2.7/site-packages/ipython-5.3.0-py2.7.egg/IPython/core/magic_arguments.py", line 60, in <module>
    from IPython.utils.text import dedent
  File "/Library/Python/2.7/site-packages/ipython-5.3.0-py2.7.egg/IPython/utils/text.py", line 21, in <module>
    from pathlib2 import Path
  File "build/bdist.macosx-10.13-intel/egg/pathlib2.py", line 45, in <module>
  File "build/bdist.macosx-10.13-intel/egg/scandir.py", line 30, in <module>
  File "build/bdist.macosx-10.13-intel/egg/_scandir.py", line 7, in <module>
  File "build/bdist.macosx-10.13-intel/egg/_scandir.py", line 4, in __bootstrap__
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources/__init__.py", line 1168, in resource_filename
    self, resource_name
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources/__init__.py", line 1876, in get_resource_filename
    self._extract_resource(manager, self._eager_to_zip(name))
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources/__init__.py", line 1936, in _extract_resource
    manager.extraction_error()
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources/__init__.py", line 1214, in extraction_error
    raise err
pkg_resources.ExtractionError: Can't extract file(s) to egg cache

The following error occurred while trying to extract file(s) to the Python egg
cache:

  [Errno 13] Permission denied: '/Users/***/.python-eggs/scandir-1.6-py2.7-macosx-10.13-intel.egg-tmp/tmpkTNwXG.$extract'

The Python egg cache directory is currently set to:

  /Users/*****/.python-eggs

Perhaps your account does not have write access to this directory?  You can change the cache directory by setting the PYTHON_EGG_CACHE environment variable to point to an accessible directory.

上面的这个问题,可以通过以下语句进行更正:

sudo chown -R *** /Users/***/.python-eggs/

再次在终端输入ipython就会显示正常的结果:

Python 2.7.10 (default, Jul 15 2017, 17:16:57) 
Type "copyright", "credits" or "license" for more information.

IPython 5.3.0 -- An enhanced Interactive Python.
?         -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help      -> Python's own help system.
object?   -> Details about 'object', use 'object??' for extra details.

安装jupyter,在终端输入 sudo pip install jupyter,但是遇到以下问题:

The directory '/Users/***/Library/Caches/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
The directory '/Users/***/Library/Caches/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Requirement already satisfied: jupyter in /Library/Python/2.7/site-packages/jupyter-1.0.0-py2.7.egg
Collecting notebook (from jupyter)
  Downloading notebook-5.4.0-py2.py3-none-any.whl (8.0MB)
    100% |████████████████████████████████| 8.0MB 187kB/s 
Collecting qtconsole (from jupyter)
  Downloading qtconsole-4.3.1-py2.py3-none-any.whl (108kB)
    100% |████████████████████████████████| 112kB 6.3MB/s 
Collecting jupyter-console (from jupyter)
  Downloading jupyter_console-5.2.0-py2.py3-none-any.whl
Collecting nbconvert (from jupyter)
  Downloading nbconvert-5.3.1-py2.py3-none-any.whl (387kB)
    100% |████████████████████████████████| 389kB 2.3MB/s 
Requirement already satisfied: ipykernel in /Library/Python/2.7/site-packages (from jupyter)
Requirement already satisfied: ipywidgets in /Library/Python/2.7/site-packages/ipywidgets-7.1.0-py2.7.egg (from jupyter)
Requirement already satisfied: jupyter-core>=4.4.0 in /Library/Python/2.7/site-packages (from notebook->jupyter)
Requirement already satisfied: traitlets>=4.2.1 in /Library/Python/2.7/site-packages/traitlets-4.3.2-py2.7.egg (from notebook->jupyter)
Requirement already satisfied: ipython-genutils in /Library/Python/2.7/site-packages/ipython_genutils-0.2.0-py2.7.egg (from notebook->jupyter)
Collecting terminado>=0.8.1 (from notebook->jupyter)
  Downloading terminado-0.8.1-py2.py3-none-any.whl
Collecting jinja2 (from notebook->jupyter)
  Downloading Jinja2-2.10-py2.py3-none-any.whl (126kB)
    100% |████████████████████████████████| 133kB 6.2MB/s 
Collecting nbformat (from notebook->jupyter)
  Downloading nbformat-4.4.0-py2.py3-none-any.whl (155kB)
    100% |████████████████████████████████| 163kB 5.3MB/s 
Collecting Send2Trash (from notebook->jupyter)
  Downloading Send2Trash-1.4.2.tar.gz
Requirement already satisfied: tornado>=4 in /Library/Python/2.7/site-packages/tornado-5.0a1-py2.7-macosx-10.13-intel.egg (from notebook->jupyter)
Requirement already satisfied: jupyter-client>=5.2.0 in /Library/Python/2.7/site-packages (from notebook->jupyter)
Requirement already satisfied: pygments in /Library/Python/2.7/site-packages/Pygments-2.2.0-py2.7.egg (from qtconsole->jupyter)
Requirement already satisfied: ipython in /Library/Python/2.7/site-packages/ipython-5.3.0-py2.7.egg (from jupyter-console->jupyter)
Requirement already satisfied: prompt-toolkit<2.0.0,>=1.0.0 in /Library/Python/2.7/site-packages/prompt_toolkit-1.0.15-py2.7.egg (from jupyter-console->jupyter)
Collecting mistune>=0.7.4 (from nbconvert->jupyter)
  Downloading mistune-0.8.3-py2.py3-none-any.whl
Collecting bleach (from nbconvert->jupyter)
  Downloading bleach-2.1.2-py2.py3-none-any.whl
Collecting testpath (from nbconvert->jupyter)
  Downloading testpath-0.3.1-py2.py3-none-any.whl (161kB)
    100% |████████████████████████████████| 163kB 4.5MB/s 
Collecting pandocfilters>=1.4.1 (from nbconvert->jupyter)
  Downloading pandocfilters-1.4.2.tar.gz
Collecting entrypoints>=0.2.2 (from nbconvert->jupyter)
  Downloading entrypoints-0.2.3-py2.py3-none-any.whl
Collecting widgetsnbextension~=3.1.0 (from ipywidgets->jupyter)
  Downloading widgetsnbextension-3.1.3-py2.py3-none-any.whl (2.2MB)
    100% |████████████████████████████████| 2.2MB 602kB/s 
Requirement already satisfied: six in ./Library/Python/2.7/lib/python/site-packages (from traitlets>=4.2.1->notebook->jupyter)
Requirement already satisfied: decorator in /Library/Python/2.7/site-packages/decorator-4.1.2-py2.7.egg (from traitlets>=4.2.1->notebook->jupyter)
Requirement already satisfied: enum34 in /Library/Python/2.7/site-packages/enum34-1.1.6-py2.7.egg (from traitlets>=4.2.1->notebook->jupyter)
Requirement already satisfied: ptyprocess; os_name != "nt" in /Library/Python/2.7/site-packages/ptyprocess-0.5.2-py2.7.egg (from terminado>=0.8.1->notebook->jupyter)
Collecting MarkupSafe>=0.23 (from jinja2->notebook->jupyter)
  Downloading MarkupSafe-1.0.tar.gz
Collecting jsonschema!=2.5.0,>=2.4 (from nbformat->notebook->jupyter)
  Downloading jsonschema-2.6.0-py2.py3-none-any.whl
Requirement already satisfied: futures in /Library/Python/2.7/site-packages/futures-3.2.0-py2.7.egg (from tornado>=4->notebook->jupyter)
Requirement already satisfied: singledispatch in /Library/Python/2.7/site-packages/singledispatch-3.4.0.3-py2.7.egg (from tornado>=4->notebook->jupyter)
Requirement already satisfied: backports_abc>=0.4 in /Library/Python/2.7/site-packages/backports_abc-0.5-py2.7.egg (from tornado>=4->notebook->jupyter)
Requirement already satisfied: pyzmq>=13 in /Library/Python/2.7/site-packages (from jupyter-client>=5.2.0->notebook->jupyter)
Requirement already satisfied: python-dateutil>=2.1 in /Library/Python/2.7/site-packages/python_dateutil-2.6.1-py2.7.egg (from jupyter-client>=5.2.0->notebook->jupyter)
Requirement already satisfied: setuptools>=18.5 in /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python (from ipython->jupyter-console->jupyter)
Requirement already satisfied: pickleshare in /Library/Python/2.7/site-packages/pickleshare-0.7.4-py2.7.egg (from ipython->jupyter-console->jupyter)
Requirement already satisfied: simplegeneric>0.8 in /Library/Python/2.7/site-packages/simplegeneric-0.8.1-py2.7.egg (from ipython->jupyter-console->jupyter)
Requirement already satisfied: backports.shutil_get_terminal_size in /Library/Python/2.7/site-packages/backports.shutil_get_terminal_size-1.0.0-py2.7.egg (from ipython->jupyter-console->jupyter)
Requirement already satisfied: pathlib2 in /Library/Python/2.7/site-packages/pathlib2-2.3.0-py2.7.egg (from ipython->jupyter-console->jupyter)
Requirement already satisfied: pexpect in /Library/Python/2.7/site-packages/pexpect-4.3.1-py2.7.egg (from ipython->jupyter-console->jupyter)
Requirement already satisfied: appnope in /Library/Python/2.7/site-packages/appnope-0.1.0-py2.7.egg (from ipython->jupyter-console->jupyter)
Requirement already satisfied: wcwidth in /Library/Python/2.7/site-packages/wcwidth-0.1.7-py2.7.egg (from prompt-toolkit<2.0.0,>=1.0.0->jupyter-console->jupyter)
Collecting html5lib!=1.0b1,!=1.0b2,!=1.0b3,!=1.0b4,!=1.0b5,!=1.0b6,!=1.0b7,!=1.0b8,>=0.99999999pre (from bleach->nbconvert->jupyter)
  Downloading html5lib-1.0.1-py2.py3-none-any.whl (117kB)
    100% |████████████████████████████████| 122kB 5.9MB/s 
Requirement already satisfied: configparser>=3.5; python_version == "2.7" in /Library/Python/2.7/site-packages (from entrypoints>=0.2.2->nbconvert->jupyter)
Collecting functools32; python_version == "2.7" (from jsonschema!=2.5.0,>=2.4->nbformat->notebook->jupyter)
  Downloading functools32-3.2.3-2.zip
Requirement already satisfied: scandir in /Library/Python/2.7/site-packages/scandir-1.6-py2.7-macosx-10.13-intel.egg (from pathlib2->ipython->jupyter-console->jupyter)
Collecting webencodings (from html5lib!=1.0b1,!=1.0b2,!=1.0b3,!=1.0b4,!=1.0b5,!=1.0b6,!=1.0b7,!=1.0b8,>=0.99999999pre->bleach->nbconvert->jupyter)
  Downloading webencodings-0.5.1-py2.py3-none-any.whl
Installing collected packages: terminado, MarkupSafe, jinja2, mistune, functools32, jsonschema, nbformat, webencodings, html5lib, bleach, testpath, pandocfilters, entrypoints, nbconvert, Send2Trash, notebook, qtconsole, jupyter-console, widgetsnbextension
  Running setup.py install for MarkupSafe ... done
  Running setup.py install for functools32 ... done
  Running setup.py install for pandocfilters ... done
  Running setup.py install for Send2Trash ... done
Exception:
Traceback (most recent call last):
  File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/basecommand.py", line 215, in main
    status = self.run(options, args)
  File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/commands/install.py", line 342, in run
    prefix=options.prefix_path,
  File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/req/req_set.py", line 784, in install
    **kwargs
  File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/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-9.0.1-py2.7.egg/pip/req/req_install.py", line 1064, in move_wheel_files
    isolated=self.isolated,
  File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/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-9.0.1-py2.7.egg/pip/wheel.py", line 316, in clobber
    ensure_dir(destdir)
  File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/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 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/etc'

经过百度,需要upgrade pip,在终端输入:pip install –upgrade pip后,再次执行 sudo pip install jupyter即可成功。

然后在终端输入jupyter notebook 启动,会默认打开http://localhost:8888/,访问用户目录。

### 回答1: 你可以使用以下命令安装 IPython Notebook: ``` pip install ipython[notebook] ``` 如果你使用的是 Anaconda,可以使用以下命令安装: ``` conda install ipython-notebook ``` 安装完成后,可以在终端或命令行输入以下命令启动 IPython Notebook: ``` jupyter notebook ``` ### 回答2: IPython Notebook是一种很方便的开发和交互环境,可以帮助我们在编写代码和调试过程中更快地进行测试和实验。在使用IPython Notebook之前,首先需要进行安装IPython Notebook安装非常简单,可以通过pip包管理器来完成,只需要执行一个命令即可完成安装。首先,确保电脑上已经安装Python和pip,然后打开命令行终端,输入以下命令即可开始安装IPython Notebook: ``` pip install ipython[all] ``` 执行完以上命令后,系统会自动下载和安装IPython Notebook及其依赖项。安装完成后,可以通过以下命令启动Notebook: ``` ipython notebook ``` 这将打开你的浏览器并显示Notebook界面。在Notebook界面中可以创建新的Notebook,执行代码,记录数据和图形,以及与其他人共享Notebook等。 如果你想要更多的定制化和优化,可以考虑使用Anaconda发行版。这是一个完整的数据科学平台,包括Python解释器、科学计算库、图形界面和工具等。你可以通过以下命令来安装Anaconda: ``` conda install anaconda ``` 通过以上几个简单的步骤,你就可以在电脑上愉快地使用IPython Notebook进行开发和调试了。 ### 回答3: ipython notebook是一个开源的交互式计算和数据可视化工具,它是python编程语言的一个交互式环境。在使用该工具之前,需要先进行安装,接下来将详细介绍ipython notebook安装。 1. 安装Python ipython notebook是基于Python的交互式计算环境,因此需要先安装Python。可以从Python官网上下载安装,推荐使用最新版的Python3。 2. 安装pip pip是Python的包管理工具,可以用来安装和卸载Python模块。如果已经安装Python,那么pip也已经自动安装了,可以通过下面的命令来检查pip是否已经安装: ``` pip --version ``` 如果pip没有安装,可以通过下面的命令来安装: ``` sudo apt-get install python3-pip ``` 3. 安装ipython 安装完pip之后,可以使用pip来安装ipython,执行下面的命令: ``` pip3 install ipython ``` 4. 安装ipython notebook ipython notebookipython的一个扩展,可以用来创建和编辑交互式笔记本。安装ipython notebook也很简单,只需要执行下面的命令: ``` pip3 install jupyter ``` 5. 启动ipython notebook 安装完成之后,可以通过下面的命令来启动ipython notebook: ``` jupyter notebook ``` 启动之后,会弹出一个网页,里面包含了一个文件浏览器和ipython notebook的交互界面。可以在文件浏览器中创建和打开.ipynb文件,也可以在交互界面中输入和运行Python代码。 6. 安装常用模块 安装ipythonipython notebook之后,可以使用pip来安装常用的Python模块,例如numpy、pandas、matplotlib等。执行下面的命令,可以一次性安装多个模块: ``` pip3 install numpy pandas matplotlib ``` 安装完成之后,就可以使用这些模块来进行数据处理和可视化了。 总结: 以上就是ipython notebook安装过程,需要安装的主要是Python、pip、ipythonipython notebook安装完成之后,可以使用ipython notebook来创建交互式笔记本,并使用常用的Python模块进行数据处理和可视化。ipython notebook使得数据分析和探索更加方便和快速,对于从事数据分析和科学计算的人员来说,是必备的工具之一。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值