web-dev-qa-db-ja.com

Python 2.7用のJupyterノートブックをインストールする

Ubuntu 14.04のPython 2.7にJupyterをインストールするにはどうすればよいですか?

私が試します:

Sudo add-apt-repository ppa:jolicloud-team/ppa
Sudo apt-get update

更新の出力:

Ign file:  InRelease
Get:1 file:  Release.gpg [181 B]
Get:2 file:  Release [196 B]                                                   
Ign file:  Translation-en_US                                                   
Ign file:  Translation-en                                                      
Hit http://storage.googleapis.com stable InRelease         
Ign http://us.archive.ubuntu.com trusty/universe Translation-en_US
Fetched 5,905 kB in 6s (915 kB/s)                                              
W: Failed to fetch http://ppa.launchpad.net/jolicloud-team/ppa/ubuntu/dists/trusty/main/binary-AMD64/Packages  404  Not Found

W: Failed to fetch http://ppa.launchpad.net/jolicloud-team/ppa/ubuntu/dists/trusty/main/binary-i386/Packages  404  Not Found

E: Some index files failed to download. They have been ignored, or old ones used instead.

その後:

Sudo apt-get install jupiter

出力:

Reading package lists... Done
Building dependency tree       
Reading state information... Done
E: Unable to locate package jupiter

更新:

mona@Pascal:~/computer_vision/imgur$ Sudo python -m pip install --upgrade --force-reinstall pip
The directory '/home/mona/.cache/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 '/home/mona/.cache/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.
Collecting pip
/usr/local/lib/python2.7/dist-packages/pip/_vendor/requests/packages/urllib3/util/ssl_.py:318: SNIMissingWarning: An HTTPS request has been made, but the SNI (Subject Name Indication) extension to TLS is not available on this platform. This may cause the server to present an incorrect TLS certificate, which can cause validation failures. You can upgrade to a newer version of Python to solve this. For more information, see https://urllib3.readthedocs.io/en/latest/security.html#snimissingwarning.
  SNIMissingWarning
/usr/local/lib/python2.7/dist-packages/pip/_vendor/requests/packages/urllib3/util/ssl_.py:122: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. You can upgrade to a newer version of Python to solve this. For more information, see https://urllib3.readthedocs.io/en/latest/security.html#insecureplatformwarning.
  InsecurePlatformWarning
  Downloading pip-9.0.1-py2.py3-none-any.whl (1.3MB)
    100% |████████████████████████████████| 1.3MB 721kB/s 
Installing collected packages: pip
  Found existing installation: pip 9.0.1
    Uninstalling pip-9.0.1:
      Successfully uninstalled pip-9.0.1
Successfully installed pip-9.0.1
/usr/local/lib/python2.7/dist-packages/pip/_vendor/requests/packages/urllib3/util/ssl_.py:122: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. You can upgrade to a newer version of Python to solve this. For more information, see https://urllib3.readthedocs.io/en/latest/security.html#insecureplatformwarning.
  InsecurePlatformWarning
mona@Pascal:~/computer_vision/imgur$ Sudo -H pip install jupyter
Collecting jupyter
/usr/local/lib/python2.7/dist-packages/pip/_vendor/requests/packages/urllib3/util/ssl_.py:318: SNIMissingWarning: An HTTPS request has been made, but the SNI (Subject Name Indication) extension to TLS is not available on this platform. This may cause the server to present an incorrect TLS certificate, which can cause validation failures. You can upgrade to a newer version of Python to solve this. For more information, see https://urllib3.readthedocs.io/en/latest/security.html#snimissingwarning.
  SNIMissingWarning
/usr/local/lib/python2.7/dist-packages/pip/_vendor/requests/packages/urllib3/util/ssl_.py:122: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. You can upgrade to a newer version of Python to solve this. For more information, see https://urllib3.readthedocs.io/en/latest/security.html#insecureplatformwarning.
  InsecurePlatformWarning
  Downloading jupyter-1.0.0-py2.py3-none-any.whl
Collecting ipywidgets (from jupyter)
  Downloading ipywidgets-5.2.2-py2.py3-none-any.whl (43kB)
    100% |████████████████████████████████| 51kB 1.1MB/s 
Collecting qtconsole (from jupyter)
  Downloading qtconsole-4.2.1-py2.py3-none-any.whl (104kB)
    100% |████████████████████████████████| 112kB 2.1MB/s 
Collecting nbconvert (from jupyter)
  Downloading nbconvert-4.2.0-py2.py3-none-any.whl (319kB)
    100% |████████████████████████████████| 327kB 1.6MB/s 
Collecting notebook (from jupyter)
  Downloading notebook-4.2.3-py2.py3-none-any.whl (6.7MB)
    100% |████████████████████████████████| 6.7MB 154kB/s 
Collecting jupyter-console (from jupyter)
  Downloading jupyter_console-5.0.0-py2.py3-none-any.whl
Collecting ipykernel (from jupyter)
  Downloading ipykernel-4.5.0-py2.py3-none-any.whl (97kB)
    100% |████████████████████████████████| 102kB 5.2MB/s 
Collecting widgetsnbextension>=1.2.6 (from ipywidgets->jupyter)
  Downloading widgetsnbextension-1.2.6-py2.py3-none-any.whl (1.5MB)
    100% |████████████████████████████████| 1.5MB 674kB/s 
Collecting ipython>=4.0.0 (from ipywidgets->jupyter)
  Downloading ipython-5.1.0-py2-none-any.whl (747kB)
    100% |████████████████████████████████| 747kB 1.2MB/s 
Collecting traitlets>=4.2.1 (from ipywidgets->jupyter)
  Downloading traitlets-4.3.1-py2.py3-none-any.whl (74kB)
    100% |████████████████████████████████| 81kB 5.2MB/s 
Collecting pygments (from qtconsole->jupyter)
  Downloading Pygments-2.1.3-py2.py3-none-any.whl (755kB)
    100% |████████████████████████████████| 757kB 1.2MB/s 
Collecting jupyter-client>=4.1 (from qtconsole->jupyter)
  Downloading jupyter_client-4.4.0-py2.py3-none-any.whl (76kB)
    100% |████████████████████████████████| 81kB 5.0MB/s 
Collecting jupyter-core (from qtconsole->jupyter)
  Downloading jupyter_core-4.2.0-py2.py3-none-any.whl (76kB)
    100% |████████████████████████████████| 81kB 5.4MB/s 
Collecting entrypoints (from nbconvert->jupyter)
  Downloading entrypoints-0.2.2-py2.py3-none-any.whl
Collecting nbformat (from nbconvert->jupyter)
  Downloading nbformat-4.1.0-py2.py3-none-any.whl (140kB)
    100% |████████████████████████████████| 143kB 4.0MB/s 
Requirement already satisfied: jinja2 in /usr/lib/python2.7/dist-packages (from nbconvert->jupyter)
Collecting mistune!=0.6 (from nbconvert->jupyter)
  Downloading mistune-0.7.3-py2.py3-none-any.whl
Collecting terminado>=0.3.3; sys_platform != "win32" (from notebook->jupyter)
  Downloading terminado-0.6.tar.gz
Collecting tornado>=4 (from notebook->jupyter)
  Downloading tornado-4.4.2.tar.gz (460kB)
    100% |████████████████████████████████| 460kB 1.9MB/s 
Collecting ipython-genutils (from notebook->jupyter)
  Downloading ipython_genutils-0.1.0-py2.py3-none-any.whl
Collecting Prompt-toolkit<2.0.0,>=1.0.0 (from jupyter-console->jupyter)
  Downloading Prompt_toolkit-1.0.9-py2-none-any.whl (241kB)
    100% |████████████████████████████████| 245kB 2.7MB/s 
Requirement already satisfied: decorator in /usr/local/lib/python2.7/dist-packages (from ipython>=4.0.0->ipywidgets->jupyter)
Requirement already satisfied: setuptools>=18.5 in /usr/local/lib/python2.7/dist-packages (from ipython>=4.0.0->ipywidgets->jupyter)
Collecting pickleshare (from ipython>=4.0.0->ipywidgets->jupyter)
  Downloading pickleshare-0.7.4-py2.py3-none-any.whl
Collecting backports.shutil-get-terminal-size; python_version == "2.7" (from ipython>=4.0.0->ipywidgets->jupyter)
  Downloading backports.shutil_get_terminal_size-1.0.0-py2.py3-none-any.whl
Requirement already satisfied: pexpect; sys_platform != "win32" in /usr/lib/python2.7/dist-packages (from ipython>=4.0.0->ipywidgets->jupyter)
Collecting pathlib2; python_version == "2.7" or python_version == "3.3" (from ipython>=4.0.0->ipywidgets->jupyter)
  Downloading pathlib2-2.1.0-py2.py3-none-any.whl
Requirement already satisfied: simplegeneric>0.8 in /usr/lib/python2.7/dist-packages (from ipython>=4.0.0->ipywidgets->jupyter)
Requirement already satisfied: six in /usr/local/lib/python2.7/dist-packages (from traitlets>=4.2.1->ipywidgets->jupyter)
Collecting enum34; python_version == "2.7" (from traitlets>=4.2.1->ipywidgets->jupyter)
  Downloading enum34-1.1.6-py2-none-any.whl
Requirement already satisfied: pyzmq>=13 in /usr/lib/python2.7/dist-packages (from jupyter-client>=4.1->qtconsole->jupyter)
Collecting configparser>=3.5; python_version == "2.7" (from entrypoints->nbconvert->jupyter)
  Downloading configparser-3.5.0.tar.gz
Collecting jsonschema!=2.5.0,>=2.0 (from nbformat->nbconvert->jupyter)
  Downloading jsonschema-2.5.1-py2.py3-none-any.whl
Requirement already satisfied: markupsafe in /usr/lib/python2.7/dist-packages (from jinja2->nbconvert->jupyter)
Collecting ptyprocess (from terminado>=0.3.3; sys_platform != "win32"->notebook->jupyter)
  Downloading ptyprocess-0.5.1-py2.py3-none-any.whl
Collecting backports.ssl_match_hostname (from tornado>=4->notebook->jupyter)
  Downloading backports.ssl_match_hostname-3.5.0.1.tar.gz
Collecting singledispatch (from tornado>=4->notebook->jupyter)
  Downloading singledispatch-3.4.0.3-py2.py3-none-any.whl
Collecting certifi (from tornado>=4->notebook->jupyter)
  Downloading certifi-2016.9.26-py2.py3-none-any.whl (377kB)
    100% |████████████████████████████████| 378kB 2.1MB/s 
Collecting backports_abc>=0.4 (from tornado>=4->notebook->jupyter)
  Downloading backports_abc-0.4-py2.py3-none-any.whl
Collecting wcwidth (from Prompt-toolkit<2.0.0,>=1.0.0->jupyter-console->jupyter)
  Downloading wcwidth-0.1.7-py2.py3-none-any.whl
Collecting functools32; python_version == "2.7" (from jsonschema!=2.5.0,>=2.0->nbformat->nbconvert->jupyter)
  Downloading functools32-3.2.3-2.Zip
Building wheels for collected packages: terminado, tornado, configparser, backports.ssl-match-hostname, functools32
  Running setup.py bdist_wheel for terminado ... done
  Stored in directory: /root/.cache/pip/wheels/3b/c2/ea/af635ffb63857a8c2ddd22da6a4b52f5b7ea3065db94ef5d7c
  Running setup.py bdist_wheel for tornado ... done
  Stored in directory: /root/.cache/pip/wheels/b3/db/47/46e05d1ee3ecfba252fcab42f0a156dab0df0cddf99fa0827c
  Running setup.py bdist_wheel for configparser ... done
  Stored in directory: /root/.cache/pip/wheels/1c/bd/b4/277af3f6c40645661b4cd1c21df26aca0f2e1e9714a1d4cda8
  Running setup.py bdist_wheel for backports.ssl-match-hostname ... done
  Stored in directory: /root/.cache/pip/wheels/5d/72/36/b2a31507b613967b728edc33378a5ff2ada0f62855b93c5ae1
  Running setup.py bdist_wheel for functools32 ... done
  Stored in directory: /root/.cache/pip/wheels/3c/d0/09/cd78d0ff4d6cfecfbd730782a7815a4571cd2cd4d2ed6e69d9
Successfully built terminado tornado configparser backports.ssl-match-hostname functools32
Installing collected packages: configparser, entrypoints, enum34, ipython-genutils, traitlets, functools32, jsonschema, jupyter-core, nbformat, pygments, mistune, nbconvert, ptyprocess, backports.ssl-match-hostname, singledispatch, certifi, backports-abc, tornado, terminado, jupyter-client, pathlib2, pickleshare, backports.shutil-get-terminal-size, wcwidth, Prompt-toolkit, ipython, ipykernel, notebook, widgetsnbextension, ipywidgets, qtconsole, jupyter-console, jupyter
  Found existing installation: tornado 3.1.1
    DEPRECATION: Uninstalling a distutils installed project (tornado) has been deprecated and will be removed in a future version. This is due to the fact that uninstalling a distutils project will only partially uninstall the project.
    Uninstalling tornado-3.1.1:
      Successfully uninstalled tornado-3.1.1
  Found existing installation: ipython 1.2.1
    DEPRECATION: Uninstalling a distutils installed project (ipython) has been deprecated and will be removed in a future version. This is due to the fact that uninstalling a distutils project will only partially uninstall the project.
    Uninstalling ipython-1.2.1:
      Successfully uninstalled ipython-1.2.1
  Rolling back uninstall of ipython
Exception:
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/pip/basecommand.py", line 215, in main
    status = self.run(options, args)
  File "/usr/local/lib/python2.7/dist-packages/pip/commands/install.py", line 342, in run
    prefix=options.prefix_path,
  File "/usr/local/lib/python2.7/dist-packages/pip/req/req_set.py", line 784, in install
    **kwargs
  File "/usr/local/lib/python2.7/dist-packages/pip/req/req_install.py", line 851, in install
    self.move_wheel_files(self.source_dir, root=root, prefix=prefix)
  File "/usr/local/lib/python2.7/dist-packages/pip/req/req_install.py", line 1064, in move_wheel_files
    isolated=self.isolated,
  File "/usr/local/lib/python2.7/dist-packages/pip/wheel.py", line 377, in move_wheel_files
    clobber(source, dest, False, fixer=fixer, filter=filter)
  File "/usr/local/lib/python2.7/dist-packages/pip/wheel.py", line 323, in clobber
    shutil.copyfile(srcfile, destfile)
  File "/usr/lib/python2.7/shutil.py", line 83, in copyfile
    with open(dst, 'wb') as fdst:
IOError: [Errno 20] Not a directory: '/usr/local/share/man/man1/ipython.1.gz'
/usr/local/lib/python2.7/dist-packages/pip/_vendor/requests/packages/urllib3/util/ssl_.py:122: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. You can upgrade to a newer version of Python to solve this. For more information, see https://urllib3.readthedocs.io/en/latest/security.html#insecureplatformwarning.
  InsecurePlatformWarning
mona@Pascal:~/computer_vision/imgur$ jupyter notebook
jupyter: 'notebook' is not a Jupyter command
mona@Pascal:~/computer_vision/imgur$ jupyter
usage: jupyter [-h] [--version] [--config-dir] [--data-dir] [--runtime-dir]
               [--paths] [--json]
               [subcommand]
jupyter: error: one of the arguments --version subcommand --config-dir --data-dir --runtime-dir --paths is required
mona@Pascal:~/computer_vision/imgur$ 
2
Mona Jalal

Ubuntu 18.04以降にJupyter Notebookをインストールする

ターミナルを開き、次を入力します。

Sudo apt install python3-notebook jupyter jupyter-core python-ipykernel  

ノートブックサーバーを起動するには、次のコマンドを実行します。

jupyter notebook

Jupyter NotebookがWebブラウザーで開いているのが見えるはずです。

Ubuntu 14.04→16.10にJupyter Notebookをインストールします

UbuntuのPythonのデフォルトバージョンは正常に機能しますが、pipは最新バージョンに更新する必要があり、pipをインストールするときは、HOME環境変数をターゲットユーザーのパスワードデータベースエントリで指定されたホームディレクトリに設定します。オプション-H

Sudo apt-get update
Sudo apt-get -y install python-pip python-dev
Sudo -H pip install --upgrade pip
Sudo apt-get -y install ipython ipython-notebook
Sudo -H pip install jupyter

Python 3.xを使用している場合は、代わりに次のコマンドを実行します。

Sudo apt-get update
Sudo apt-get -y install python3-pip python3-dev
Sudo -H pip3 install --upgrade pip
Sudo apt-get -y install ipython3 ipython3-notebook
Sudo -H pip3 install jupyter

Jupyter Notebookを起動するには、次のコマンドを実行します。

jupyter notebook  

Python-matplotlibもインストールされている場合、現在のノートブックでプロットを有効にするコードの最初の行は%matplotlib inlineです。

Python 2のカーネルを追加することで、Python 2のJupyter NotebookでPython 3を使用できます。Python 3、次のようなPython 2カーネルをセットアップできます。

python2 -m pip install ipykernel
python2 -m ipykernel install --user  

Ubuntu 17.04および17.10にJupyterノートブックをインストールする

Ubuntu 17.04以降では、デフォルトのUbuntuリポジトリでJupyter Notebookを使用でき、aptを使用してすばやく簡単にインストールできます。ターミナルを開き、次を入力します。

Sudo apt install jupyter-notebook jupyter-core python-ipykernel 

python-ipykernelは、Python 2.xプログラムをJupyter Notebookで実行するために必要です。それ以外の場合はPython 3.xのみをサポートします。

ノートブックサーバーを起動するには、次のコマンドを実行します。

jupyter notebook

Jupyter NotebookがWebブラウザーで開いているのが見えるはずです。

4
karel