LoginSignup
14
12

More than 5 years have passed since last update.

pyenv で管理しているpythonのバージョンを更新する

Last updated at Posted at 2016-05-11

内容

pyenvを古いままにしておいたために、pyenvで公開されている最新のpython環境を構築したい時にlocalのpyenvに該当のバージョンが入っていないために構築できない… ということが起きて、その回避策を調べていたのですが、思いの外出くわさなかったので、メモしておきます。

前提

pyenvを使ってMacにPythonの環境を構築するのようにgithubからpyenvの環境を作った場合でのやり方です。

やったこと

やったことはすごく単純で、pyenvで公開されているpythonのバージョンはgitで管理されているのでpullするだけです。

cd /path/to/pyenv #上記のリンクの場合、`~/.pyenv`に相当します。

ls -a #`/path/to/pyenv`の中に`.git`が含まれているかを確認します。

# `.git`があればgitでのバージョン管理をしているので、git pullをします。
git pull origin

pyenv install でタブ補完をするとインストールすることができるpythonのバージョンが増えていることが分かるかと思います。

感想

以上でpyenvで管理するpythonのバージョンを最新にする手順は完了です。
gitを使っているので、当たり前といえば当たり前なのですが、誰かの助けになれば幸いです。

おまけ

新しいpythonのバージョンをインストールしたら怒られた

実際にpyenvで新しくバージョンをインストールしようとしたときに以下のようなエラーで怒られました。

$ pyenv install anaconda3-2.5.0
Downloading Anaconda3-2.5.0-MacOSX-x86_64.sh...
-> https://repo.continuum.io/archive/Anaconda3-2.5.0-MacOSX-x86_64.sh
error: failed to download Anaconda3-2.5.0-MacOSX-x86_64.sh

BUILD FAILED (OS X 10.11.4 using python-build 20151006-248-g2017dd0)

Inspect or clean up the working tree at /var/folders/46/hzj7hl91109bbg6j97vn91x4ht3y4y/T/python-build.20160511102611.58100
Results logged to /var/folders/46/hzj7hl91109bbg6j97vn91x4ht3y4y/T/python-build.20160511102611.58100.log

Last 10 log lines:
/var/folders/46/hzj7hl91109bbg6j97vn91x4ht3y4y/T/python-build.20160511102611.58100 ~/git/hogehoge
curl: (56) SSLRead() return error -36

curlがいけない?
ぐぐりました。
Git Clone Fails with sslRead() error on OS X Yosemiteで最も支持を得ている回避策で解決できました。

$ brew reinstall git --with-brewed-curl --with-brewed-openssl
==> Reinstalling git with --with-brewed-curl, --with-brewed-openssl
==> Installing dependencies for git: curl
==> Installing git dependency: curl
==> Downloading https://homebrew.bintray.com/bottles/curl-7.48.0.el_capitan.bottle.1.tar.gz
######################################################################## 100.0%
==> Pouring curl-7.48.0.el_capitan.bottle.1.tar.gz
==> Caveats
This formula is keg-only, which means it was not symlinked into /usr/local.

OS X already provides this software and installing another version in
parallel can cause all kinds of trouble.

Generally there are no consequences of this for you. If you build your
own software and it requires this formula, you'll need to add to your
build variables:

    LDFLAGS:  -L/usr/local/opt/curl/lib
    CPPFLAGS: -I/usr/local/opt/curl/include


zsh completion has been installed to:
  /usr/local/share/zsh/site-functions
==> Summary
🍺  /usr/local/Cellar/curl/7.48.0: 362 files, 2.5M
==> Installing git
==> Downloading https://www.kernel.org/pub/software/scm/git/git-2.8.1.tar.xz
######################################################################## 100.0%
==> make install prefix=/usr/local/Cellar/git/2.8.1 sysconfdir=/usr/local/etc CC=clang CFLAGS= LDFLAGS=
==> make CC=clang CFLAGS= LDFLAGS=
==> make clean
==> make CC=clang CFLAGS= LDFLAGS=
==> Downloading https://www.kernel.org/pub/software/scm/git/git-manpages-2.8.1.tar.xz
######################################################################## 100.0%
==> Downloading https://www.kernel.org/pub/software/scm/git/git-htmldocs-2.8.1.tar.xz
######################################################################## 100.0%
==> Caveats
The OS X keychain credential helper has been installed to:
  /usr/local/bin/git-credential-osxkeychain

The "contrib" directory has been installed to:
  /usr/local/share/git-core/contrib

Bash completion has been installed to:
  /usr/local/etc/bash_completion.d

zsh completion has been installed to:
  /usr/local/share/zsh/site-functions

Emacs Lisp files have been installed to:
  /usr/local/share/emacs/site-lisp/git
==> Summary
🍺  /usr/local/Cellar/git/2.8.1: 1,418 files, 31.4M, built in 40 seconds

$ pyenv install anaconda3-2.5.0
Downloading Anaconda3-2.5.0-MacOSX-x86_64.sh...
-> https://repo.continuum.io/archive/Anaconda3-2.5.0-MacOSX-x86_64.sh
Installing Anaconda3-2.5.0-MacOSX-x86_64...
Installed Anaconda3-2.5.0-MacOSX-x86_64 to /Users/a13660/.pyenv/versions/anaconda3-2.5.0

$ pyenv local anaconda3-2.5.0

$ pyenv rehash

$ python -V
Python 3.5.1 :: Anaconda 2.5.0 (x86_64)

目的のバージョンに更新することができましたー。

14
12
2

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
14
12