ubuntu 安装 pythonenv
This will get you going with the latest version of pyenv and make it easy to fork and contribute any changes back upstream.
-
Check out pyenv where you want it installed. A good place to choose is
$HOME/.pyenv(but you can install it somewhere else).$ git clone https://github.com/yyuu/pyenv.git ~/.pyenv -
Define environment variable
PYENV_ROOTto point to the path where pyenv repo is cloned and add$PYENV_ROOT/binto your$PATHfor access to thepyenvcommand-line utility.$ echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.bash_profile $ echo 'export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bash_profileZsh note: Modify your
~/.zshenvfile instead of~/.bash_profile. Ubuntu note: Modify your~/.bashrcfile instead of~/.bash_profile. -
Add
pyenv initto your shell to enable shims and autocompletion. Please make sureeval "$(pyenv init -)"is placed toward the end of the shell configuration file since it manipulatesPATHduring the initialization.$ echo 'eval "$(pyenv init -)"' >> ~/.bash_profileZsh note: Modify your
~/.zshenvfile instead of~/.bash_profile. Ubuntu note: Modify your~/.bashrcfile instead of~/.bash_profile.General warning: There are some systems where the
BASH_ENVvariable is configured to point to.bashrc. On such systems you should almost certainly put the abovementioned lineeval "$(pyenv init -)into.bash_profile, andnot into.bashrc. Otherwise you may observe strange behaviour, such aspyenvgetting into an infinite loop. See #264for details. -
Restart your shell so the path changes take effect. You can now begin using pyenv.
$ exec $SHELL -
Install Python versions into
$PYENV_ROOT/versions. For example, to download and install Python 2.7.8, run:$ pyenv install 2.7.8
浙公网安备 33010602011771号