Jupyter notebook が使いたかったのだが、Ubuntu 16.04.6 LTS の公式リポジトリにはそれらしいのがなかったため、
pip3 で入れようとしたところ以下のように言われた。
なぜか pip3 が以下のようにまともに動かなくなってしまった。
上記ページでは、sudo して python で uninstall pip してから apt で再度 install してるけど、
ユーザーモードで pip upgrade したためか、以下のようにユーザーモードで python から uninstall pip するだけで、apt による再 install はしなくても復旧した。
pip3 で入れようとしたところ以下のように言われた。
$ pip3 install jupyter プログラム 'pip3' はまだインストールされていません。 次のように入力することでインストールできます: sudo apt install python3-pip言われるがまま、
sudo apt install python3-pipとして pip3 を導入した後再度 install を試みたところ
$ pip3 install jupyter Collecting jupyter Downloading https://files.pythonhosted.org/packages/83/df/0f5dd132200728a86190397e1ea87cd76244e42d39ec5e88efd25b2abd7e/jupyter-1.0.0-py2.py3-none-any.whl ... Successfully built pandocfilters tornado prometheus-client backcall pyrsistent Installing collected packages: pyzmq, ipython-genutils, decorator, six, traitlets, jupyter-core, attrs, pyrsistent, setuptools, jsonschema, nbformat, pygments, webencodings, bleach, testpath, entrypoints, mistune, MarkupSafe, jinja2, defusedxml, pandocfilters, nbconvert, tornado, Send2Trash, python-dateutil, jupyter-client, pickleshare, ptyprocess, pexpect, wcwidth, prompt-toolkit, parso, jedi, backcall, ipython, ipykernel, terminado, prometheus-client, notebook, widgetsnbextension, ipywidgets, qtconsole, jupyter-console, jupyter Successfully installed MarkupSafe-0.23 Send2Trash attrs backcall bleach decorator-4.0.6 defusedxml entrypoints ipykernel ipython-2.4.1 ipython-genutils ipywidgets jedi-0.9.0 jinja2-2.8 jsonschema jupyter jupyter-client jupyter-console jupyter-core mistune nbconvert nbformat notebook pandocfilters parso pexpect-4.0.1 pickleshare prometheus-client prompt-toolkit ptyprocess-0.5 pygments-2.1 pyrsistent python-dateutil-2.4.2 pyzmq-15.2.0 qtconsole setuptools-20.7.0 six-1.10.0 terminado testpath tornado traitlets wcwidth webencodings widgetsnbextension You are using pip version 8.1.1, however version 19.1.1 is available. You should consider upgrading via the 'pip install --upgrade pip' command.のように成功したのだが、 pip を upgrade しろというので言われるがままに upgrade してみると
$ pip3 install --upgrade pip Collecting pip Downloading https://files.pythonhosted.org/packages/5c/e0/be401c003291b56efc55aeba6a80ab790d3d4cece2778288d65323009420/pip-19.1.1-py2.py3-none-any.whl (1.4MB) 100% |████████████████████████████████| 1.4MB 1.5MB/s Installing collected packages: pip Successfully installed pip-19.1.1のように成功したように見えたのだが、
なぜか pip3 が以下のようにまともに動かなくなってしまった。
$ pip3 Traceback (most recent call last): File "/usr/bin/pip3", line 9, in <module> from pip import main ImportError: cannot import name 'main'やる気なくしたので自棄糞気味に「Traceback (most recent call last): File "/usr/bin/pip3", line 9, in [module] from pip import main ImportError: cannot import name 'main'」とかググってみると以下のページが見つかった。
- KOKENSHAの技術ブログ / 2018-06-19: Python pip3 – pip upgradeした後 「cannot import name ‘main’ 」error
上記ページでは、sudo して python で uninstall pip してから apt で再度 install してるけど、
ユーザーモードで pip upgrade したためか、以下のようにユーザーモードで python から uninstall pip するだけで、apt による再 install はしなくても復旧した。
$ python3 -m pip uninstall pip Uninstalling pip-19.1.1: Would remove: /home/kou/.local/bin/pip /home/kou/.local/bin/pip3 /home/kou/.local/bin/pip3.5 /home/kou/.local/lib/python3.5/site-packages/pip-19.1.1.dist-info/* /home/kou/.local/lib/python3.5/site-packages/pip/* Proceed (y/n)? Your response ('') was not one of the expected responses: y, n Proceed (y/n)? y Successfully uninstalled pip-19.1.1
$ pip3 Usage: pip <command> [options] Commands: install Install packages. download Download packages. uninstall Uninstall packages. freeze Output installed packages in requirements format. list List installed packages. show Show information about installed packages. search Search PyPI for packages. wheel Build wheels from your requirements. hash Compute hashes of package archives. completion A helper command used for command completion help Show help for commands. General Options: -h, --help Show help. --isolated Run pip in an isolated mode, ignoring environment variables and user configuration. -v, --verbose Give more output. Option is additive, and can be used up to 3 times. -V, --version Show version and exit. -q, --quiet Give less output. --log <path> Path to a verbose appending log. --proxy <proxy> Specify a proxy in the form [user:passwd@]proxy.server:port. --retries <retries> Maximum number of retries each connection should attempt (default 5 times). --timeout <sec> Set the socket timeout (default 15 seconds). --exists-action <action> Default action when a path already exists: (s)witch, (i)gnore, (w)ipe, (b)ackup. --trusted-host <hostname> Mark this host as trusted, even though it does not have valid or any HTTPS. --cert <path> Path to alternate CA bundle. --client-cert <path> Path to SSL client certificate, a single file containing the private key and the certificate in PEM format. --cache-dir <dir> Store the cache data in <dir>. --no-cache-dir Disable the cache. --disable-pip-version-check Don't periodically check PyPI to determine whether a new version of pip is available for download. Implied with --no-index.
タグ
コメントをかく