日別アーカイブ: 2018年10月29日

pyenvでCentOS7にpython3.7.0をインストール

環境

CentOS Linux release 7.5.1804 (Core)
pyenv 1.2.7

依存パッケージインストール

pyenvの公式のwikiにある推奨される依存関係をまとめてインストール。

yum install gcc zlib-devel bzip2 bzip2-devel readline-devel sqlite sqlite-devel openssl-devel tk-devel libffi-devel

pythonインストール実施

[yoshitake@localhost ~]$ pyenv install 3.7.0
(略)
[yoshitake@localhost ~]$ pyenv versions
* system (set by /home/yoshitake/.pyenv/version)
3.7.0

切り替え

[yoshitake@localhost ~]$ pyenv global 3.7.0
[yoshitake@localhost ~]$ pyenv versions 
  system
* 3.7.0 (set by /home/yoshitake/.pyenv/version)

インストール失敗のログ

zlib本体はもとから入っていたけど、読めないと言われてインストール失敗。
zlib-develが入っていなかったからこのメッセージになった?

[yoshitake@localhost ~]$ pyenv install 3.7.0
Downloading Python-3.7.0.tar.xz...
-> https://www.python.org/ftp/python/3.7.0/Python-3.7.0.tar.xz
Installing Python-3.7.0...

BUILD FAILED (CentOS 7.5.1804 using python-build 20180424)

Inspect or clean up the working tree at /tmp/python-build.20181029194007.1745
Results logged to /tmp/python-build.20181029194007.1745.log

Last 10 log lines:
  File "/tmp/python-build.20181029194007.1745/Python-3.7.0/Lib/ensurepip/__main__.py", line 5, in 
    sys.exit(ensurepip._main())
  File "/tmp/python-build.20181029194007.1745/Python-3.7.0/Lib/ensurepip/__init__.py", line 204, in _main
    default_pip=args.default_pip,
  File "/tmp/python-build.20181029194007.1745/Python-3.7.0/Lib/ensurepip/__init__.py", line 117, in _bootstrap
    return _run_pip(args + [p[0] for p in _PROJECTS], additional_paths)
  File "/tmp/python-build.20181029194007.1745/Python-3.7.0/Lib/ensurepip/__init__.py", line 27, in _run_pip
    import pip._internal
zipimport.ZipImportError: can't decompress data; zlib not available

zlib本体はもとから入っていた

[yoshitake@localhost ~]$ sudo yum install zlib -y
[sudo] yoshitake のパスワード:
読み込んだプラグイン:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: mirrors.cat.net
 * extras: mirrors.cat.net
 * updates: mirrors.cat.net
パッケージ zlib-1.2.7-17.el7.x86_64 はインストール済みか最新バージョンです
何もしません