WSL の Ubuntu 18.04 に SciPy をインストールしてみました

Jupyter Notebook と NumPy と pandas を個別にインストールしていたのですが、まとめて使いたいので SciPy をインストールしようと思いました。

環境

  • Ubuntu 18.04 LTS
  • Pipenv 2018.05.18
  • Jupyter Notebook 5.2.0
  • Matplotlib 2.2.2
  • NumPy 1.14.4
  • pandas 0.23.0
  • SciPy 1.1.0

SciPy

You can install packages via commands such as:

python -m pip install --user numpy scipy matplotlib ipython jupyter pandas sympy nose

Installing via pip

これを見ると、結局個別にインストールするのと変わらず、 pip でそれぞれインストールしてあげればいいみたいでした。

SciPy のトップのページを見ると、次のパッケージが主なものになっているようです。

  • NumPy
  • SciPy Libraly
  • Matplotlib
  • IPython
  • Sympy
  • pandas

pandas をインストールすると依存する NumPy も一緒にインストールされるのですけれども。

nose は知らなかったのですが、 Python のロギングに関するパッケージのようでした。

中途半端に Jupyter Notebook と pandas だけインストールしておくよりも、 SciPy まとめてインストールしておいた方がわかりやすいかなと思います。

install

以前、 Pipenv の環境を作ったので、 Pipenv でインストールしてみます。

$ pipenv install numpy scipy matplotlib ipython jupyter pandas sympy nose
Creating a virtualenv for this project…
Using /usr/bin/python3 (3.6.5) to create virtualenv…
⠋Already using interpreter /usr/bin/python3
Using base prefix '/usr'
New python executable in /home/user/.local/share/virtualenvs/scipy-aTjO8tFO/bin/python3
Also creating executable in /home/user/.local/share/virtualenvs/scipy-aTjO8tFO/bin/python
Installing setuptools, pip, wheel...done.

Virtualenv location: /home/user/.local/share/virtualenvs/scipy-aTjO8tFO
Creating a Pipfile for this project…                                                                                  Installing numpy…
                                                                                                                                                                                                                                                                                                                                                 Collecting numpy
  Downloading https://files.pythonhosted.org/packages/4b/3d/9c0a34ad8544abef864714840fb8954d630b04433f00881bc8fde7b2ab27/numpy-1.14.4-cp36-cp36m-manylinux1_x86_64.whl (12.2MB)
Installing collected packages: numpy
Successfully installed numpy-1.14.4

Adding numpy to Pipfile's [packages]…
Installing scipy…
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               Collecting scipy
  Downloading https://files.pythonhosted.org/packages/a8/0b/f163da98d3a01b3e0ef1cab8dd2123c34aee2bafbb1c5bffa354cc8a1730/scipy-1.1.0-cp36-cp36m-manylinux1_x86_64.whl (31.2MB)
Requirement already satisfied: numpy>=1.8.2 in /home/user/.local/share/virtualenvs/scipy-aTjO8tFO/lib/python3.6/site-packages (from scipy) (1.14.4)
Installing collected packages: scipy
Successfully installed scipy-1.1.0

Adding scipy to Pipfile's [packages]…
Installing matplotlib…
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   Collecting matplotlib
  Downloading https://files.pythonhosted.org/packages/49/b8/89dbd27f2fb171ce753bb56220d4d4f6dbc5fe32b95d8edc4415782ef07f/matplotlib-2.2.2-cp36-cp36m-manylinux1_x86_64.whl (12.6MB)
Requirement already satisfied: numpy>=1.7.1 in /home/user/.local/share/virtualenvs/scipy-aTjO8tFO/lib/python3.6/site-packages (from matplotlib) (1.14.4)
Collecting kiwisolver>=1.0.1 (from matplotlib)
  Downloading https://files.pythonhosted.org/packages/69/a7/88719d132b18300b4369fbffa741841cfd36d1e637e1990f27929945b538/kiwisolver-1.0.1-cp36-cp36m-manylinux1_x86_64.whl (949kB)
Collecting pytz (from matplotlib)
  Downloading https://files.pythonhosted.org/packages/dc/83/15f7833b70d3e067ca91467ca245bae0f6fe56ddc7451aa0dc5606b120f2/pytz-2018.4-py2.py3-none-any.whl (510kB)
Collecting cycler>=0.10 (from matplotlib)
  Downloading https://files.pythonhosted.org/packages/f7/d2/e07d3ebb2bd7af696440ce7e754c59dd546ffe1bbe732c8ab68b9c834e61/cycler-0.10.0-py2.py3-none-any.whl
Collecting six>=1.10 (from matplotlib)
  Downloading https://files.pythonhosted.org/packages/67/4b/141a581104b1f6397bfa78ac9d43d8ad29a7ca43ea90a2d863fe3056e86a/six-1.11.0-py2.py3-none-any.whl
Collecting python-dateutil>=2.1 (from matplotlib)
  Downloading https://files.pythonhosted.org/packages/cf/f5/af2b09c957ace60dcfac112b669c45c8c97e32f94aa8b56da4c6d1682825/python_dateutil-2.7.3-py2.py3-none-any.whl (211kB)
Collecting pyparsing!=2.0.4,!=2.1.2,!=2.1.6,>=2.0.1 (from matplotlib)
  Downloading https://files.pythonhosted.org/packages/6a/8a/718fd7d3458f9fab8e67186b00abdd345b639976bc7fb3ae722e1b026a50/pyparsing-2.2.0-py2.py3-none-any.whl (56kB)
Requirement already satisfied: setuptools in /home/user/.local/share/virtualenvs/scipy-aTjO8tFO/lib/python3.6/site-packages (from kiwisolver>=1.0.1->matplotlib) (39.2.0)
Installing collected packages: kiwisolver, pytz, six, cycler, python-dateutil, pyparsing, matplotlib
Successfully installed cycler-0.10.0 kiwisolver-1.0.1 matplotlib-2.2.2 pyparsing-2.2.0 python-dateutil-2.7.3 pytz-2018.4 six-1.11.0

Adding matplotlib to Pipfile's [packages]…
Installing ipython…
                                                                                                                                                                                                                                                                                                                                                                                                                                                                 Collecting ipython
  Downloading https://files.pythonhosted.org/packages/b1/7f/91d50f28af3e3a24342561983a7857e399ce24093876e6970b986a0b6677/ipython-6.4.0-py3-none-any.whl (750kB)
Requirement already satisfied: setuptools>=18.5 in /home/user/.local/share/virtualenvs/scipy-aTjO8tFO/lib/python3.6/site-packages (from ipython) (39.2.0)
Collecting pygments (from ipython)
  Downloading https://files.pythonhosted.org/packages/02/ee/b6e02dc6529e82b75bb06823ff7d005b141037cb1416b10c6f00fc419dca/Pygments-2.2.0-py2.py3-none-any.whl (841kB)
Collecting backcall (from ipython)
  Downloading https://files.pythonhosted.org/packages/84/71/c8ca4f5bb1e08401b916c68003acf0a0655df935d74d93bf3f3364b310e0/backcall-0.1.0.tar.gz
Collecting pexpect; sys_platform != "win32" (from ipython)
  Downloading https://files.pythonhosted.org/packages/89/e6/b5a1de8b0cc4e07ca1b305a4fcc3f9806025c1b651ea302646341222f88b/pexpect-4.6.0-py2.py3-none-any.whl (57kB)
Collecting simplegeneric>0.8 (from ipython)
  Downloading https://files.pythonhosted.org/packages/3d/57/4d9c9e3ae9a255cd4e1106bb57e24056d3d0709fc01b2e3e345898e49d5b/simplegeneric-0.8.1.zip
Collecting prompt-toolkit<2.0.0,>=1.0.15 (from ipython)
  Downloading https://files.pythonhosted.org/packages/04/d1/c6616dd03701e7e2073f06d5c3b41b012256e42b72561f16a7bd86dd7b43/prompt_toolkit-1.0.15-py3-none-any.whl (247kB)
Collecting pickleshare (from ipython)
  Downloading https://files.pythonhosted.org/packages/9f/17/daa142fc9be6b76f26f24eeeb9a138940671490b91cb5587393f297c8317/pickleshare-0.7.4-py2.py3-none-any.whl
Collecting traitlets>=4.2 (from ipython)
  Downloading https://files.pythonhosted.org/packages/93/d6/abcb22de61d78e2fc3959c964628a5771e47e7cc60d53e9342e21ed6cc9a/traitlets-4.3.2-py2.py3-none-any.whl (74kB)
Collecting decorator (from ipython)
  Downloading https://files.pythonhosted.org/packages/bc/bb/a24838832ba35baf52f32ab1a49b906b5f82fb7c76b2f6a7e35e140bac30/decorator-4.3.0-py2.py3-none-any.whl
Collecting jedi>=0.10 (from ipython)
  Downloading https://files.pythonhosted.org/packages/e7/42/074192a165622e645ed4aeade63e76e56b3496a044569b3c6cae3a918352/jedi-0.12.0-py2.py3-none-any.whl (172kB)
Collecting ptyprocess>=0.5 (from pexpect; sys_platform != "win32"->ipython)
  Downloading https://files.pythonhosted.org/packages/ff/4e/fa4a73ccfefe2b37d7b6898329e7dbcd1ac846ba3a3b26b294a78a3eb997/ptyprocess-0.5.2-py2.py3-none-any.whl
Requirement already satisfied: six>=1.9.0 in /home/user/.local/share/virtualenvs/scipy-aTjO8tFO/lib/python3.6/site-packages (from prompt-toolkit<2.0.0,>=1.0.15->ipython) (1.11.0)
Collecting wcwidth (from prompt-toolkit<2.0.0,>=1.0.15->ipython)
  Downloading https://files.pythonhosted.org/packages/7e/9f/526a6947247599b084ee5232e4f9190a38f398d7300d866af3ab571a5bfe/wcwidth-0.1.7-py2.py3-none-any.whl
Collecting ipython-genutils (from traitlets>=4.2->ipython)
  Downloading https://files.pythonhosted.org/packages/fa/bc/9bd3b5c2b4774d5f33b2d544f1460be9df7df2fe42f352135381c347c69a/ipython_genutils-0.2.0-py2.py3-none-any.whl
Collecting parso>=0.2.0 (from jedi>=0.10->ipython)
  Downloading https://files.pythonhosted.org/packages/cd/3e/5908f9577dbd1e5df53e64349bfd11e46b726c1e4d8cd676bbe8aa4de316/parso-0.2.1-py2.py3-none-any.whl (91kB)
Building wheels for collected packages: backcall, simplegeneric
  Running setup.py bdist_wheel for backcall: started
  Running setup.py bdist_wheel for backcall: finished with status 'done'
  Stored in directory: /home/user/.cache/pip/wheels/98/b0/dd/29e28ff615af3dda4c67cab719dd51357597eabff926976b45
  Running setup.py bdist_wheel for simplegeneric: started
  Running setup.py bdist_wheel for simplegeneric: finished with status 'done'
  Stored in directory: /home/user/.cache/pip/wheels/a9/28/53/f24776b4c5bcbe91aaf1f1e247bd6fadd17191aa12fac63902
Successfully built backcall simplegeneric
Installing collected packages: pygments, backcall, ptyprocess, pexpect, simplegeneric, wcwidth, prompt-toolkit, pickleshare, decorator, ipython-genutils, traitlets, parso, jedi, ipython
Successfully installed backcall-0.1.0 decorator-4.3.0 ipython-6.4.0 ipython-genutils-0.2.0 jedi-0.12.0 parso-0.2.1 pexpect-4.6.0 pickleshare-0.7.4 prompt-toolkit-1.0.15 ptyprocess-0.5.2 pygments-2.2.0 simplegeneric-0.8.1 traitlets-4.3.2 wcwidth-0.1.7

Adding ipython to Pipfile's [packages]…
Installing jupyter…
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            Collecting jupyter
  Downloading https://files.pythonhosted.org/packages/83/df/0f5dd132200728a86190397e1ea87cd76244e42d39ec5e88efd25b2abd7e/jupyter-1.0.0-py2.py3-none-any.whl
Collecting jupyter-console (from jupyter)
  Downloading https://files.pythonhosted.org/packages/77/82/6469cd7fccf7958cbe5dce2e623f1e3c5e27f1bb1ad36d90519bc2d5d370/jupyter_console-5.2.0-py2.py3-none-any.whl
Collecting ipywidgets (from jupyter)
  Downloading https://files.pythonhosted.org/packages/7d/24/fabc09ad81c6071159a4d12d5bfbddcbea69bd9e3b16c3250ef300c0285f/ipywidgets-7.2.1-py2.py3-none-any.whl (106kB)
Collecting qtconsole (from jupyter)
  Downloading https://files.pythonhosted.org/packages/90/ff/047e0dca2627b162866920e7aa93f04523c0ae81e5c67060eec85701992d/qtconsole-4.3.1-py2.py3-none-any.whl (108kB)
Collecting nbconvert (from jupyter)
  Downloading https://files.pythonhosted.org/packages/39/ea/280d6c0d92f8e3ca15fd798bbcc2ea141489f9539de7133d8fe10ea4b049/nbconvert-5.3.1-py2.py3-none-any.whl (387kB)
Collecting ipykernel (from jupyter)
  Downloading https://files.pythonhosted.org/packages/ab/3f/cd624c835aa3336a9110d0a99e15070f343b881b7d651ab1375ef226a3ac/ipykernel-4.8.2-py3-none-any.whl (108kB)
Collecting notebook (from jupyter)
  Downloading https://files.pythonhosted.org/packages/c0/66/cfed59f574d03ca5f1b7c5281485a9cc9a0f21342d24e0f057572316dae5/notebook-5.5.0-py2.py3-none-any.whl (8.4MB)
Collecting jupyter-client (from jupyter-console->jupyter)
  Downloading https://files.pythonhosted.org/packages/94/dd/fe6c4d683b09eb05342bd2816b7779663f71762b4fa9c2d5203d35d17354/jupyter_client-5.2.3-py2.py3-none-any.whl (89kB)
Requirement already satisfied: prompt-toolkit<2.0.0,>=1.0.0 in /home/user/.local/share/virtualenvs/scipy-aTjO8tFO/lib/python3.6/site-packages (from jupyter-console->jupyter) (1.0.15)
Requirement already satisfied: pygments in /home/user/.local/share/virtualenvs/scipy-aTjO8tFO/lib/python3.6/site-packages (from jupyter-console->jupyter) (2.2.0)
Requirement already satisfied: ipython in /home/user/.local/share/virtualenvs/scipy-aTjO8tFO/lib/python3.6/site-packages (from jupyter-console->jupyter) (6.4.0)
Collecting nbformat>=4.2.0 (from ipywidgets->jupyter)
  Downloading https://files.pythonhosted.org/packages/da/27/9a654d2b6cc1eaa517d1c5a4405166c7f6d72f04f6e7eea41855fe808a46/nbformat-4.4.0-py2.py3-none-any.whl (155kB)
Requirement already satisfied: traitlets>=4.3.1 in /home/user/.local/share/virtualenvs/scipy-aTjO8tFO/lib/python3.6/site-packages (from ipywidgets->jupyter) (4.3.2)
Collecting widgetsnbextension~=3.2.0 (from ipywidgets->jupyter)
  Downloading https://files.pythonhosted.org/packages/ff/fa/64acc09fc845a6b2dc0724d6f3f81e829b778ed5e9a7559567b4f19a3f4b/widgetsnbextension-3.2.1-py2.py3-none-any.whl (2.2MB)
Requirement already satisfied: ipython-genutils in /home/user/.local/share/virtualenvs/scipy-aTjO8tFO/lib/python3.6/site-packages (from qtconsole->jupyter) (0.2.0)
Collecting jupyter-core (from qtconsole->jupyter)
  Downloading https://files.pythonhosted.org/packages/1d/44/065d2d7bae7bebc06f1dd70d23c36da8c50c0f08b4236716743d706762a8/jupyter_core-4.4.0-py2.py3-none-any.whl (126kB)
Collecting entrypoints>=0.2.2 (from nbconvert->jupyter)
  Downloading https://files.pythonhosted.org/packages/cc/8b/4eefa9b47f1910b3d2081da67726b066e379b04ca897acfe9f92bac56147/entrypoints-0.2.3-py2.py3-none-any.whl
Collecting mistune>=0.7.4 (from nbconvert->jupyter)
  Downloading https://files.pythonhosted.org/packages/c8/8c/87f4d359438ba0321a2ae91936030110bfcc62fef752656321a72b8c1af9/mistune-0.8.3-py2.py3-none-any.whl
Collecting jinja2 (from nbconvert->jupyter)
  Downloading https://files.pythonhosted.org/packages/7f/ff/ae64bacdfc95f27a016a7bed8e8686763ba4d277a78ca76f32659220a731/Jinja2-2.10-py2.py3-none-any.whl (126kB)
Collecting testpath (from nbconvert->jupyter)
  Downloading https://files.pythonhosted.org/packages/15/19/d7bc380c479a184e4a5a9ce516e4e2a773165f89b445f7cdced83d94de25/testpath-0.3.1-py2.py3-none-any.whl (161kB)
Collecting pandocfilters>=1.4.1 (from nbconvert->jupyter)
  Downloading https://files.pythonhosted.org/packages/4c/ea/236e2584af67bb6df960832731a6e5325fd4441de001767da328c33368ce/pandocfilters-1.4.2.tar.gz
Collecting bleach (from nbconvert->jupyter)
  Downloading https://files.pythonhosted.org/packages/30/b6/a8cffbb9ab4b62b557c22703163735210e9cd857d533740c64e1467d228e/bleach-2.1.3-py2.py3-none-any.whl
Collecting tornado>=4.0 (from ipykernel->jupyter)
  Downloading https://files.pythonhosted.org/packages/cf/d1/3be271ae5eba9fb59df63c9891fdc7d8044b999e8ac145994cdbfd2ae66a/tornado-5.0.2.tar.gz (506kB)
Collecting pyzmq>=17 (from notebook->jupyter)
  Downloading https://files.pythonhosted.org/packages/58/0e/d40ee65acabb0776ccdade96812adc0438051ef6cff1ddbe4da463604867/pyzmq-17.0.0-cp36-cp36m-manylinux1_x86_64.whl (3.1MB)
Collecting terminado>=0.8.1 (from notebook->jupyter)
  Downloading https://files.pythonhosted.org/packages/2e/20/a26211a24425923d46e1213b376a6ee60dc30bcdf1b0c345e2c3769deb1c/terminado-0.8.1-py2.py3-none-any.whl
Collecting Send2Trash (from notebook->jupyter)
  Downloading https://files.pythonhosted.org/packages/49/46/c3dc27481d1cc57b9385aff41c474ceb7714f7935b1247194adae45db714/Send2Trash-1.5.0-py3-none-any.whl
Requirement already satisfied: python-dateutil>=2.1 in /home/user/.local/share/virtualenvs/scipy-aTjO8tFO/lib/python3.6/site-packages (from jupyter-client->jupyter-console->jupyter) (2.7.3)
Requirement already satisfied: six>=1.9.0 in /home/user/.local/share/virtualenvs/scipy-aTjO8tFO/lib/python3.6/site-packages (from prompt-toolkit<2.0.0,>=1.0.0->jupyter-console->jupyter) (1.11.0)
Requirement already satisfied: wcwidth in /home/user/.local/share/virtualenvs/scipy-aTjO8tFO/lib/python3.6/site-packages (from prompt-toolkit<2.0.0,>=1.0.0->jupyter-console->jupyter) (0.1.7)
Requirement already satisfied: pexpect; sys_platform != "win32" in /home/user/.local/share/virtualenvs/scipy-aTjO8tFO/lib/python3.6/site-packages (from ipython->jupyter-console->jupyter) (4.6.0)
Requirement already satisfied: decorator in /home/user/.local/share/virtualenvs/scipy-aTjO8tFO/lib/python3.6/site-packages (from ipython->jupyter-console->jupyter) (4.3.0)
Requirement already satisfied: setuptools>=18.5 in /home/user/.local/share/virtualenvs/scipy-aTjO8tFO/lib/python3.6/site-packages (from ipython->jupyter-console->jupyter) (39.2.0)
Requirement already satisfied: backcall in /home/user/.local/share/virtualenvs/scipy-aTjO8tFO/lib/python3.6/site-packages (from ipython->jupyter-console->jupyter) (0.1.0)
Requirement already satisfied: simplegeneric>0.8 in /home/user/.local/share/virtualenvs/scipy-aTjO8tFO/lib/python3.6/site-packages (from ipython->jupyter-console->jupyter) (0.8.1)
Requirement already satisfied: jedi>=0.10 in /home/user/.local/share/virtualenvs/scipy-aTjO8tFO/lib/python3.6/site-packages (from ipython->jupyter-console->jupyter) (0.12.0)
Requirement already satisfied: pickleshare in /home/user/.local/share/virtualenvs/scipy-aTjO8tFO/lib/python3.6/site-packages (from ipython->jupyter-console->jupyter) (0.7.4)
Collecting jsonschema!=2.5.0,>=2.4 (from nbformat>=4.2.0->ipywidgets->jupyter)
  Downloading https://files.pythonhosted.org/packages/77/de/47e35a97b2b05c2fadbec67d44cfcdcd09b8086951b331d82de90d2912da/jsonschema-2.6.0-py2.py3-none-any.whl
Collecting MarkupSafe>=0.23 (from jinja2->nbconvert->jupyter)
  Downloading https://files.pythonhosted.org/packages/4d/de/32d741db316d8fdb7680822dd37001ef7a448255de9699ab4bfcbdf4172b/MarkupSafe-1.0.tar.gz
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 https://files.pythonhosted.org/packages/a5/62/bbd2be0e7943ec8504b517e62bab011b4946e1258842bc159e5dfde15b96/html5lib-1.0.1-py2.py3-none-any.whl (117kB)
Requirement already satisfied: ptyprocess; os_name != "nt" in /home/user/.local/share/virtualenvs/scipy-aTjO8tFO/lib/python3.6/site-packages (from terminado>=0.8.1->notebook->jupyter) (0.5.2)
Requirement already satisfied: parso>=0.2.0 in /home/user/.local/share/virtualenvs/scipy-aTjO8tFO/lib/python3.6/site-packages (from jedi>=0.10->ipython->jupyter-console->jupyter) (0.2.1)
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 https://files.pythonhosted.org/packages/f4/24/2a3e3df732393fed8b3ebf2ec078f05546de641fe1b667ee316ec1dcf3b7/webencodings-0.5.1-py2.py3-none-any.whl
Building wheels for collected packages: pandocfilters, tornado, MarkupSafe
  Running setup.py bdist_wheel for pandocfilters: started
  Running setup.py bdist_wheel for pandocfilters: finished with status 'done'
  Stored in directory: /home/user/.cache/pip/wheels/39/01/56/f1b08a6275acc59e846fa4c1e1b65dbc1919f20157d9e66c20
  Running setup.py bdist_wheel for tornado: started
  Running setup.py bdist_wheel for tornado: finished with status 'done'
  Stored in directory: /home/user/.cache/pip/wheels/29/8c/cf/6a5a8f6e35d877c0cb72b109d21c34981504897ce9a605e599
  Running setup.py bdist_wheel for MarkupSafe: started
  Running setup.py bdist_wheel for MarkupSafe: finished with status 'done'
  Stored in directory: /home/user/.cache/pip/wheels/33/56/20/ebe49a5c612fffe1c5a632146b16596f9e64676768661e4e46
Successfully built pandocfilters tornado MarkupSafe
Installing collected packages: pyzmq, jupyter-core, tornado, jupyter-client, ipykernel, jupyter-console, jsonschema, nbformat, terminado, MarkupSafe, jinja2, entrypoints, mistune, testpath, pandocfilters, webencodings, html5lib, bleach, nbconvert, Send2Trash, notebook, widgetsnbextension, ipywidgets, qtconsole, jupyter
Successfully installed MarkupSafe-1.0 Send2Trash-1.5.0 bleach-2.1.3 entrypoints-0.2.3 html5lib-1.0.1 ipykernel-4.8.2 ipywidgets-7.2.1 jinja2-2.10 jsonschema-2.6.0 jupyter-1.0.0 jupyter-client-5.2.3 jupyter-console-5.2.0 jupyter-core-4.4.0 mistune-0.8.3 nbconvert-5.3.1 nbformat-4.4.0 notebook-5.5.0 pandocfilters-1.4.2 pyzmq-17.0.0 qtconsole-4.3.1 terminado-0.8.1 testpath-0.3.1 tornado-5.0.2 webencodings-0.5.1 widgetsnbextension-3.2.1

Adding jupyter to Pipfile's [packages]…
Installing pandas…
                                                                                                                                                                                                                                                                                                                                                                                                                                                Collecting pandas
  Downloading https://files.pythonhosted.org/packages/69/ec/8ff0800b8594691759b78a42ccd616f81e7099ee47b167eb9bbd502c02b9/pandas-0.23.0-cp36-cp36m-manylinux1_x86_64.whl (11.7MB)
Requirement already satisfied: pytz>=2011k in /home/user/.local/share/virtualenvs/scipy-aTjO8tFO/lib/python3.6/site-packages (from pandas) (2018.4)
Requirement already satisfied: python-dateutil>=2.5.0 in /home/user/.local/share/virtualenvs/scipy-aTjO8tFO/lib/python3.6/site-packages (from pandas) (2.7.3)
Requirement already satisfied: numpy>=1.9.0 in /home/user/.local/share/virtualenvs/scipy-aTjO8tFO/lib/python3.6/site-packages (from pandas) (1.14.4)
Requirement already satisfied: six>=1.5 in /home/user/.local/share/virtualenvs/scipy-aTjO8tFO/lib/python3.6/site-packages (from python-dateutil>=2.5.0->pandas) (1.11.0)
Installing collected packages: pandas
Successfully installed pandas-0.23.0

Adding pandas to Pipfile's [packages]…
Installing sympy…
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        Collecting sympy
  Downloading https://files.pythonhosted.org/packages/91/26/4e477dbd1f9260eb743d9f221af3044648a8fb2fcf3f2f23daee4dc831a4/sympy-1.1.1.tar.gz (4.6MB)
Collecting mpmath>=0.19 (from sympy)
  Downloading https://files.pythonhosted.org/packages/7a/05/b3d1472885d8dc0606936ea5da0ccb1b4785682e78ab15e34ada24aea8d5/mpmath-1.0.0.tar.gz (511kB)
Building wheels for collected packages: sympy, mpmath
  Running setup.py bdist_wheel for sympy: started
  Running setup.py bdist_wheel for sympy: finished with status 'done'
  Stored in directory: /home/user/.cache/pip/wheels/6d/47/7c/40a7cd9b9bd5bad329fcd21d8e50629700fcc6e5520a66a2de
  Running setup.py bdist_wheel for mpmath: started
  Running setup.py bdist_wheel for mpmath: finished with status 'done'
  Stored in directory: /home/user/.cache/pip/wheels/33/15/0f/9ca5f2ad88a5456803098daa189f382408a81556aa209e97ff
Successfully built sympy mpmath
Installing collected packages: mpmath, sympy
Successfully installed mpmath-1.0.0 sympy-1.1.1

Adding sympy to Pipfile's [packages]…
Installing nose…
                                                                       Collecting nose
  Downloading https://files.pythonhosted.org/packages/15/d8/dd071918c040f50fa1cf80da16423af51ff8ce4a0f2399b7bf8de45ac3d9/nose-1.3.7-py3-none-any.whl (154kB)
Installing collected packages: nose
Successfully installed nose-1.3.7

Adding nose to Pipfile's [packages]…
Pipfile.lock not found, creating…
Locking [dev-packages] dependencies…
Locking [packages] dependencies…
Updated Pipfile.lock (984317)!
Installing dependencies from Pipfile.lock (984317)…
  🐍   ▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉ 52/52 — 00:00:19
To activate this project's virtualenv, run the following:
 $ pipenv shell

Locking [packages] dependencies… (下から 6 行目)が表示されたのが開始から 6 分程度でした。 そこからまた時間がかかって、 $ pipenv shell (一番下)が表示されたのが開始から 17 分 45 秒程度でした。

$ ls -l
total 28
-rw-rw-rw- 1 user user   243 Jun 10 14:35 Pipfile
-rw-r--r-- 1 user user 26577 Jun 10 14:47 Pipfile.lock

そんなに大きくないみたいですけれども。

Jupyter Notebook

確認のために Jupyter Notebook を起動してみます。

$ pipenv run jupyter notebook --no-browser &

WSL の Ubuntu だとブラウザーがないので --no-browser のオプションをつけてブラウザーを起動しないようにしています。

それから、プロンプトが戻ってきてほしいので、 & をつけてバックグラウンドで実行しています。

[1] 555
[I 14:52:52.291 NotebookApp] Writing notebook server cookie secret to /home/user/.local/share/jupyter/runtime/notebook_cookie_secret
[I 14:52:52.979 NotebookApp] Serving notebooks from local directory: /home/user/scipy
[I 14:52:52.980 NotebookApp] 0 active kernels
[I 14:52:52.980 NotebookApp] The Jupyter Notebook is running at:
[I 14:52:52.981 NotebookApp] http://localhost:8888/?token=6f81ff1fae3aa523861284ae7a84bbf0f0b594c444e7943b
[I 14:52:52.981 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
[C 14:52:52.983 NotebookApp]

    Copy/paste this URL into your browser when you connect for the first time,
    to login with a token:
        http://localhost:8888/?token=6f81ff1fae3aa523861284ae7a84bbf0f0b594c444e7943b&token=6f81ff1fae3aa523861284ae7a84bbf0f0b594c444e7943b

起動できたみたいです。

NumPy, pandas, Matplotlib

Jupyter Notebook で NumPy と pandas と Matplotlib を使ってみます。

matplotlib のマジックコマンドとモジュールを読み込みました。

%matplotlib inline
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt

以前、最大ドローダウンを計算したときのサンプルのデータを作りました。

s = pd.Series(np.random.randn(1000))
s2 = s.cumsum()
s3 = s2.cummax()

グラフを表示してみました。

plt.plot(s2, label='cumsum')
plt.plot(s3, label='cummax')
plt.legend(loc='best')
plt.show()

結果です。

最大ドローダウンを表示してみました。

(s3 - s2).max()

結果です。

46.51264733206409

終わり

Pipenv の遅さが気になりました。 10 分以上もかかるなんて。 こういうものかな。