[pyenv] zipimport.ZipImportError: can’t decompress data; zlib not available

[pyenv] zipimport.ZipImportError: can’t decompress data; zlib not available

会社でpipが使えないので、家でダウンロードして、モジュールを持っていくことに。
まずは、会社のpythonとバージョンを合わせます。

$ pyenv install 3.7.3
python-build: use openssl 1.0 from homebrew
python-build: use readline from homebrew
Downloading Python-3.7.3.tar.xz...
-> https://www.python.org/ftp/python/3.7.3/Python-3.7.3.tar.xz
Installing Python-3.7.3...
python-build: use readline from homebrew

BUILD FAILED (OS X 10.14.6 using python-build 20180424)

Inspect or clean up the working tree at /var/folders/tp/7ck2hmbd3hd29wrpwqfbjbz00000gn/T/python-build.20190907090613.22085
Results logged to /var/folders/tp/7ck2hmbd3hd29wrpwqfbjbz00000gn/T/python-build.20190907090613.22085.log

Last 10 log lines:
  File "/private/var/folders/tp/7ck2hmbd3hd29wrpwqfbjbz00000gn/T/python-build.20190907090613.22085/Python-3.7.3/Lib/ensurepip/__main__.py", line 5, in <module>
    sys.exit(ensurepip._main())
  File "/private/var/folders/tp/7ck2hmbd3hd29wrpwqfbjbz00000gn/T/python-build.20190907090613.22085/Python-3.7.3/Lib/ensurepip/__init__.py", line 204, in _main
    default_pip=args.default_pip,
  File "/private/var/folders/tp/7ck2hmbd3hd29wrpwqfbjbz00000gn/T/python-build.20190907090613.22085/Python-3.7.3/Lib/ensurepip/__init__.py", line 117, in _bootstrap
    return _run_pip(args + [p[0] for p in _PROJECTS], additional_paths)
  File "/private/var/folders/tp/7ck2hmbd3hd29wrpwqfbjbz00000gn/T/python-build.20190907090613.22085/Python-3.7.3/Lib/ensurepip/__init__.py", line 27, in _run_pip
    import pip._internal
zipimport.ZipImportError: can't decompress data; zlib not available
make: *** [install] Error 1

というエラーが出ました。

Mojave用のmacOS SDK headerが入っていないのが原因のようです。

$ sudo installer -pkg /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg -target /
Password:
installer: Package name is macOS_SDK_headers_for_macOS_10.14
installer: Installing at base path /
installer: The install was successful.
$ pyenv install 3.7.3
python-build: use openssl 1.0 from homebrew
python-build: use readline from homebrew
Downloading Python-3.7.3.tar.xz...
-> https://www.python.org/ftp/python/3.7.3/Python-3.7.3.tar.xz
Installing Python-3.7.3...
python-build: use readline from homebrew
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 (OS X 10.14.6 using python-build 20180424)

Inspect or clean up the working tree at /var/folders/tp/7ck2hmbd3hd29wrpwqfbjbz00000gn/T/python-build.20190907092313.37137
Results logged to /var/folders/tp/7ck2hmbd3hd29wrpwqfbjbz00000gn/T/python-build.20190907092313.37137.log

Last 10 log lines:
			install|*) ensurepip="" ;; \
		esac; \
		 ./python.exe -E -m ensurepip \
			$ensurepip --root=/ ; \
	fi
Looking in links: /var/folders/tp/7ck2hmbd3hd29wrpwqfbjbz00000gn/T/tmp5xwqmmtv
Collecting setuptools
Collecting pip
Installing collected packages: setuptools, pip
Successfully installed pip-19.0.3 setuptools-40.8.0

うまくいきました。

コメントする

メールアドレスが公開されることはありません。 * が付いている欄は必須項目です

*

このサイトはスパムを低減するために Akismet を使っています。コメントデータの処理方法の詳細はこちらをご覧ください