Gangmax Blog

自由之思想,独立之精神

The Python RVM Equivalent: Pyenv

| Comments

I was wondering if there is something in the Python world just like RVM in the Ruby world. So I get pyenv.

Here is the instructions to install pyenv(from here):

1
2
3
4
5
6
7
8
9
10
# Get the pyenv source code.
git clone https://github.com/yyuu/pyenv.git ~/.pyenv
# Put the following lines into the end of the "~/.bashrc" file. I am using Ubuntu.
export PYENV_ROOT="$HOME/.pyenv"
export PATH="$PYENV_ROOT/bin:$PATH"
eval "$(pyenv init -)"
# For zsh, Modify your "~/.zshenv" file instead of the "~/.bashrc" file, and
# adding the following line into your "~/.zshrc" file to make sure zsh can find
# the pyenv command:
export PATH="$HOME/.pyenv/shims:$HOME/.pyenv/bin:$PATH" # Add pyenv

How to use:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# First open a new terminal or run "source ~/.bashrc" to make the change
# takes effect. Then run the following commands.
# 1. Run the following command to know what Python versions can be
# installed. It's A LOT!
pyenv install -l
# 2. Install one.
pyenv install 2.7.10
# 3. Make the installation takes effect.
pyenv rehash
# 4. Check the current installed environments and which one is taking effect.
pyenv versions
# 5. Use the specific environment.
pyenv local 2.7.10
# 6. Install a package for the current environment.
pip list
pip install paramiko
pip list

Comments