2015-10-24 10 views
11

Ich möchte Pyenv verwenden, um Python2 und Python3 zu wechseln.Kann Python mit Pyenv nicht wechseln

Ich habe erfolgreich Python2 und Python3 und Pyenv mit folgenden Codes heruntergeladen.

brew install pyenv 

brew install pyenv-virtualenv 

pyenv install 2.7.10 

pyenv install 3.5.0 

Allerdings kann ich nicht von python2 zu python3 wechseln ..

Soma-Suzuki:~ Soma$ python --version 
Python 2.7.10 
Soma-Suzuki:~ Soma$ pyenv global 
2.7.10 
Soma-Suzuki:~ Soma$ pyenv versions 
    system 
* 2.7.10 (set by /Users/Soma/.pyenv/version) 
    3.5.0 
Soma-Suzuki:~ Soma$ pyenv global 3.5.0 
Soma-Suzuki:~ Soma$ pyenv global 
3.5.0 
Soma-Suzuki:~ Soma$ pyenv versions 
    system 
    2.7.10 
* 3.5.0 (set by /Users/Soma/.pyenv/version) 
Soma-Suzuki:~ Soma$ python --version 
Python 2.7.10 
Soma-Suzuki:~ Soma$ 

Ich verstehe nicht, warum dies geschieht.

Zu Ihrer Information. Mein Python befindet sich in diesem Verzeichnis.

Soma-Suzuki:~ Soma$ which python 
/usr/bin/python 

Vielen Dank im Voraus.

+0

Sie können nur Ihre .bashrc-Datei bearbeiten. Machen Sie alias python = Python 3.5.0 –

Antwort

30

versuchen Sie dies: eval "$ (pyenv init -)"

Beispiel:

$ python -V 
Python 2.7.9 
mac:~ $ eval "$(pyenv init -)" 
mac:~ $ python -V 
Python 3.5.0 

weitere Informationen: https://github.com/yyuu/pyenv

5

Sie haben vergessen, in diesen eval "$(pyenv init -)" auf der 1. Zeile hinzuzufügen. bash_profile-Datei (wenn Sie einen Mac verwenden) oder .bashrc-Datei.

+0

nach der Dokumentation, die es gegen Ende der Datei sein sollte – Jonathan