8
5

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

macOSでpyenvを使うまでに何度か失敗したので

Last updated at Posted at 2018-12-07

なかなかpyenvでpython3.6が入らなかったので、備忘として。

  • OS

    • macOS Mojave 10.14.1
  • 入れたいpythonのバージョン

    • 3.6.5

pyenvをインストール

$ brew install pyenv

3.6.5を入れようとしたが失敗

$ pyenv install 3.6.5

...
zipimport.ZipImportError: can't decompress data; zlib not available
make: *** [install] Error 1

https://qiita.com/zreactor/items/c3fd04417e0d61af0afe
を参考に、macOSのSDK headerの入れてみます。

また失敗

$ sudo installer -pkg /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg -target /

...
installer: Error - the package path specified was invalid: '/Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg'.

まず、xcode-selectが入っていなかったみたいです。

xcodeのインストール

$ xcode-select --install

macOSのSDK headerのインストール

$ sudo installer -pkg /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg -target /

installer: Package name is macOS_SDK_headers_for_macOS_10.14
installer: Installing at base path /
installer: The install was successful.

またまた失敗

$ pyenv install 3.6.5    

...
PermissionError: [Errno 13] Permission denied: '/lib/python3.6'

sudoでやれとのこと。

またまたまた失敗

$ sudo pyenv install 3.6.5

...
PermissionError: [Errno 1] Operation not permitted: '/bin/easy_install-3.6'
make: *** [install] Error 2

~/.pydistutils.cfgがあると、エラーになるとのことです。

成功!!

$ sudo pyenv install 3.6.5

...
python-build: use openssl from homebrew
python-build: use readline from homebrew
Downloading Python-3.6.5.tar.xz...
-> https://www.python.org/ftp/python/3.6.5/Python-3.6.5.tar.xz
Installing Python-3.6.5...
python-build: use readline from homebrew
Installed Python-3.6.5 to /Users/<user>/.pyenv/versions/3.6.5

まとめ

pipenvを使うためにpyenvを入れる上で、困っている人がいたらぜひ参考にしてください。

8
5
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
8
5

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?