Bash on Ubuntu on Windowsにおけるpyenv経由でのPythonインストール
Bash on Ubuntu on Windowsにおいてpyenv経由でPythonを入れようとしたら軽くハマったのでメモ。
pyenv自体のインストールはドキュメント通りで問題無くできます。
さてさくっと入れるか。
[~] pyenv install 3.6.1 Downloading Python-3.6.1.tar.xz... -> https://www.python.org/ftp/python/3.6.1/Python-3.6.1.tar.xz Installing Python-3.6.1... BUILD FAILED (Ubuntu 14.04 using python-build 1.0.10-2-geef042a) Inspect or clean up the working tree at /tmp/python-build.20170401003019.1617 Results logged to /tmp/python-build.20170401003019.1617.log Last 10 log lines: checking for --with-universal-archs... no checking MACHDEP... linux checking for --without-gcc... no checking for --with-icc... no checking for gcc... no checking for cc... no checking for cl.exe... no configure: error: in `/tmp/python-build.20170401003019.1617/Python-3.6.1': configure: error: no acceptable C compiler found in $PATH See `config.log' for more details
C compilerがないっぽい。gcc入れる。
[~] sudo apt-get install gcc
再トライ。
[~] pyenv install 3.6.1 Downloading Python-3.6.1.tar.xz... -> https://www.python.org/ftp/python/3.6.1/Python-3.6.1.tar.xz Installing Python-3.6.1... BUILD FAILED (Ubuntu 14.04 using python-build 1.0.10-2-geef042a) Inspect or clean up the working tree at /tmp/python-build.20170401004019.6758 Results logged to /tmp/python-build.20170401004019.6758.log Last 10 log lines: creating Modules/Setup creating Modules/Setup.local creating Makefile If you want a release build with all optimizations active (LTO, PGO, etc), please run ./configure --enable-optimizations /home/braitom/.pyenv/plugins/python-build/bin/python-build: 行 746: make: コマンドが見つかりません
今度はmakeがない。ですよね。ごめんなさい入れます。
[~] sudo apt-get install make
今度こそ。
[~] pyenv install 3.6.1 Downloading Python-3.6.1.tar.xz... -> https://www.python.org/ftp/python/3.6.1/Python-3.6.1.tar.xz Installing Python-3.6.1... BUILD FAILED (Ubuntu 14.04 using python-build 1.0.10-2-geef042a) Inspect or clean up the working tree at /tmp/python-build.20170401004228.15164 Results logged to /tmp/python-build.20170401004228.15164.log Last 10 log lines: File "/tmp/python-build.20170401004228.15164/Python-3.6.1/Lib/ensurepip/__main__.py", line 4, in <module> ensurepip._main() File "/tmp/python-build.20170401004228.15164/Python-3.6.1/Lib/ensurepip/__init__.py", line 189, in _main default_pip=args.default_pip, File "/tmp/python-build.20170401004228.15164/Python-3.6.1/Lib/ensurepip/__init__.py", line 102, in bootstrap _run_pip(args + [p[0] for p in _PROJECTS], additional_paths) File "/tmp/python-build.20170401004228.15164/Python-3.6.1/Lib/ensurepip/__init__.py", line 27, in _run_pip import pip zipimport.ZipImportError: can't decompress data; zlib not available make: *** [install] エラー 1
zlibがないっぽい。すいません入れます。
[~] sudo apt-get install zlib1g-dev
4度目の正直。
[~] pyenv install 3.6.1 Downloading Python-3.6.1.tar.xz... -> https://www.python.org/ftp/python/3.6.1/Python-3.6.1.tar.xz Installing Python-3.6.1... WARNING: The Python bz2 extension was not compiled. Missing the bzip2 lib? WARNING: The Python readline extension was not compiled. Missing the GNU readline lib? ERROR: The Python ssl extension was not compiled. Missing the OpenSSL lib? Please consult to the Wiki page to fix the problem. https://github.com/pyenv/pyenv/wiki/Common-build-problems BUILD FAILED (Ubuntu 14.04 using python-build 1.0.10-2-geef042a) Inspect or clean up the working tree at /tmp/python-build.20170401005207.30873 Results logged to /tmp/python-build.20170401005207.30873.log Last 10 log lines: upgrade) ensurepip="--upgrade" ;; \ install|*) ensurepip="" ;; \ esac; \ ./python -E -m ensurepip \ $ensurepip --root=/ ; \ fi Collecting setuptools Collecting pip Installing collected packages: setuptools, pip Successfully installed pip-9.0.1 setuptools-28.8.0
あれ? ここで気づきました。そうだこれはUbuntuだった。
結論
ということで最初にまるっといれておけばOKです。
[~] sudo apt-get install git gcc make openssl libssl-dev libbz2-dev libreadline-dev libsqlite3-dev