私は Vine Linux をよく使っていたが、最近はもっぱら Ubuntu である。 というのも、Windows 10 Home Edition や Windows 11 Home Edition で Ubuntu が使えるからだ (Windows 10 や 11 で Vine Linux は使えない)。 これはWindows (Service|Subsystem) for Linux (WSL) と呼ばれる。 この詳細は省略する。以下はすべて、WSL 上での結果である。
Ubuntu へは、標準で Python2 系(Python 2.7) と Pytyon3 系(Python 3.4)が入っている(2017-08-27 現在)。 しかし、pip は入っていない。Python2 系の pip と Python3 系の pip3 を入れたので報告する。 概要は Python2 と Python3 の共存(blog.yubais.net) に基づく。
https://pypi.python.org/pypi/distribute にアクセスし、 distribute-0.6.49.tar.gz をダウンロードする。 distribute 0.7.3 のほうがバージョンが上だが、何があるかわからない。上記リンク先に従う。
ダウンロードした gzip ファイルを展開する。
$ tar zvxf distribute-0.6.49.tar.gz $ cd distribute-0.6.49 $ sudo python3 setup.py install (中略) Installed /usr/local/lib/python3.4/dist-packages/distribute-0.6.49-py3.4.egg Processing dependencies for distribute==0.6.49Finished processing dependencies for distribute==0.6.49 After install bootstrap. Creating /usr/local/lib/python3.4/dist-packages/setuptools-0.6c11-py3.4.egg-info Creating /usr/local/lib/python3.4/dist-packages/setuptools.pth
準備が整ったので pip3 を展開する。
$ cd /usr/local/lib/python3.4/dist-packages/distribute-0.6.49-py3.4.egg $ sudo python3 easy_install.py pip (中略) Installing pip script to /usr/local/bin Installing pip3.4 script to /usr/local/bin Installing pip3 script to /usr/local/bin
この状態で、pip, pip3, pip3.4 という実行ファイルができている。これらはすべて同じで、 Python3 のインストールを行う。 そこで、Python2 のインストールを行なうために、pip2 を用意する。
$ cd distribute-0.6.49 $ sudo python setup.py install (中略) Installed /usr/local/lib/python2.7/dist-packages/distribute-0.6.49-py2.7.egg Processing dependencies for distribute==0.6.49Finished processing dependencies for distribute==0.6.49 After install bootstrap. Creating /usr/local/lib/python2.7/dist-packages/setuptools-0.6c11-py2.7.egg-info Creating /usr/local/lib/python2.7/dist-packages/setuptools.pth
準備が整ったので pip (実質は pip2)を展開する。
$ cd /usr/local/lib/python2.7/dist-packages/distribute-0.6.49-py2.7.egg $ sudo python easy_install.py pip (中略) Installing pip script to /usr/local/bin Installing pip2.7 script to /usr/local/bin Installing pip2 script to /usr/local/bin (後略)
では、pip のバージョンがどのようになっているかを見よう。
$ pip --version pip 9.0.1 from /usr/local/lib/python2.7/dist-packages/pip-9.0.1-py2.7.egg (python 2.7) $ pip2 --version pip 9.0.1 from /usr/local/lib/python2.7/dist-packages/pip-9.0.1-py2.7.egg (python 2.7) $ pip2.7 --version pip 9.0.1 from /usr/local/lib/python2.7/dist-packages/pip-9.0.1-py2.7.egg (python 2.7) $ pip3 --version pip 9.0.1 from /usr/local/lib/python3.4/dist-packages/pip-9.0.1-py3.4.egg (python 3.4) $ pip3.4 --version pip 9.0.1 from /usr/local/lib/python3.4/dist-packages/pip-9.0.1-py3.4.egg (python 3.4)
Ansible は構成管理ツールである。pip2 を使ってインストールしようとしたが、失敗した。
$ sudo pip2 install ansible (中略) Running setup.py install for pycparser ... done Running setup.py install for pycrypto ... error Complete output from command /usr/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-gs58hP/pycr ypto/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(co de, __file__, 'exec'))" install --record /tmp/pip-G64u1P-record/install-record.txt --single-version-externally-managed - -compile: running install (中略) x86_64-linux-gnu-gcc -pthread -fno-strict-aliasing -fwrapv -Wall -Wstrict-prototypes -fPIC -std=c99 -O3 -fomit-frame -pointer -Isrc/ -I/usr/include/python2.7 -c src/MD2.c -o build/temp.linux-x86_64-2.7/src/MD2.o src/MD2.c:31:20: fatal error: Python.h: そのようなファイルやディレクトリはありません #include "Python.h" ^ compilation terminated. error: command 'x86_64-linux-gnu-gcc' failed with exit status 1 ---------------------------------------- Command "/usr/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-gs58hP/pycrypto/setup.py';f=getattr (tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-G64u1P-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-build-gs58hP/pycrypto/ $
pycrypto のインストールでしくじっているのがわかる。最初に pycrpto だけインストールしてみたらどうか。
$ sudo pip install pycrypto
これも同様に失敗する。
http://phicdy.hatenablog.com/entry/pycrypto-install-centos7minimal
これを見ると、#include "Python.h" は python-devel がないためのようである。ただし、Ubuntu では、python-devel ではなく、python-dev である。
$ sudo apt-get install python-dev
新規まき直しである。
$ sudo pip install pycrypto (中略) Installing collected packages: pycrypto Running setup.py install for pycrypto ... done Successfully installed pycrypto-2.6.1
コンパイルすらまったくしないように見えるが、いいのだろうか。
$ sudo pip install ansible (中略) Installing collected packages: ansible Running setup.py install for ansible ... done Successfully installed ansible-2.3.2.0
無事インストールできたようだ。
Ubuntu をアップグレードすることにした。
$ uname
Linux xxxxxx-PC 4.4.0-17134-Microsoft #706-Microsoft Mon Apr 01 18:13:00 PST 2019 x86_64 x86_64 x86_64 GNU/Linux
$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 16.04.5 LTS
Release: 16.04
Codename: xenial
$ sudo apt update
[sudo] password for xxxxxx:(パスワードを入力)
Hit:1 http://ftp.jaist.ac.jp/pub/Linux/ubuntu xenial InRelease
Get:2 http://ftp.jaist.ac.jp/pub/Linux/ubuntu xenial-updates InRelease [109 kB]
Get:3 http://ftp.jaist.ac.jp/pub/Linux/ubuntu xenial-updates/main Sources [335 kB]
Get:4 http://ftp.jaist.ac.jp/pub/Linux/ubuntu xenial-updates/restricted Sources [2,536 B]
Get:5 http://ftp.jaist.ac.jp/pub/Linux/ubuntu xenial-updates/universe Sources [253 kB]
Get:6 http://ftp.jaist.ac.jp/pub/Linux/ubuntu xenial-updates/multiverse Sources [8,764 B]
Get:7 http://ftp.jaist.ac.jp/pub/Linux/ubuntu xenial-updates/main amd64 Packages [938 kB]
Get:8 http://ftp.jaist.ac.jp/pub/Linux/ubuntu xenial-updates/main Translation-en [376 kB]
Get:9 http://ftp.jaist.ac.jp/pub/Linux/ubuntu xenial-updates/restricted amd64 Packages [7,616 B]
Get:10 http://ftp.jaist.ac.jp/pub/Linux/ubuntu xenial-updates/restricted Translation-en [2,272 B]
Get:11 http://ftp.jaist.ac.jp/pub/Linux/ubuntu xenial-updates/universe amd64 Packages [745 kB]
Get:12 http://ftp.jaist.ac.jp/pub/Linux/ubuntu xenial-updates/universe Translation-en [310 kB]
Get:13 http://ftp.jaist.ac.jp/pub/Linux/ubuntu xenial-updates/multiverse amd64 Packages [16.7 kB]
Get:14 http://ftp.jaist.ac.jp/pub/Linux/ubuntu xenial-updates/multiverse Translation-en [8,440 B]
Fetched 3,112 kB in 14s (217 kB/s)
Reading package lists... Done
Building dependency tree
Reading state information... Done
161 packages can be upgraded. Run 'apt list --upgradable' to see them.
$ sudo apt upgrade
( 長い時間がかかる。)
$ uname -a
Linux XXXXXX-PC 4.4.0-17134-Microsoft #706-Microsoft Mon Apr 01 18:13:00 PST 2019 x86_64 x86_64 x86_64 GNU/Linux
$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 16.04.6 LTS
Release: 16.04
Codename: xenial
Ubuntu 16 のまま使ってきたが、 かなり古くなってきたので Ubuntu 20.04 にアップグレードすることにした。 なお、私の環境は WSL であり、WSL2 ではない。
ともかく、Ubuntu 16 をアンインストールして、Ubuntu 20 を導入した。 これは問題なくいった。
以降、WSL については、Windows Subsystem for Linuxを参照。
まりんきょ学問所 > UNIX 手習い > Ubuntu Linux