PyEnv – simple python version management

PyEnv - simple python version Management

pyenv is a utility that allows you to easily switch between multiple versions of Python. This is very useful when developing SOFTWARE, when there are several different versions and they need to be supported. pyenv is a great tool for managing multiple versions of Python. Even if you already have Python installed on your system, it’s worth installing pyenv so you can easily try out new language features or help contribute to a project that’s on a different version of Python.
pyenv does…

  1. Let you change the global Python version on a per-user basis.
  2. Provide support for per-project Python versions.
  3. Allow you to override the Python version with an environment variable.
  4. Search commands from multiple versions of Python at a time. This may be helpful to test across Python versions with tox.

Installation latest version into Linux Mint:dependences

sudo apt-get install -y make build-essential libssl-dev zlib1g-dev libbz2-dev libreadline-dev libsqlite3-dev wget curl llvm libncurses5-dev libncursesw5-dev xz-utils tk-dev libffi-dev liblzma-dev python-openssl git -y
auto install
curl https://pyenv.run | bash
or
curl -L https://github.com/pyenv/pyenv-installer/raw/master/bin/pyenv-installer | bash
Add this few strings
export PATH=”$HOME/.pyenv/bin:$PATH”eval “$(pyenv init -)”eval “$(pyenv virtualenv-init -)”
to the end of the file ~/.bashrc and save it
xed ~/.bashrc

installation of PyEnv to linux - simple python version management

Restart your shell

exec $SHELL
DONE! How to use
In order to see which versions of python are currently supported, there is a command:
pyenv install -l
To install any version, use:
pyenv install 2.7.16pyenv install 3.5.7
Look what is available in the system:
pyenv versions
To switch to the desired version, use:
pyenv local 2.7.16

Also, you can use:
pyenv local some_project
For global use, you can also set the desired version(s):
pyenv global 3.5.7 2.7.16
You can set a specific Python version for a shell, for example:
pyenv shell 3.5.7
pyenv shell 3.5.7
What does it look like in the picture:

installation of PyEnv to linux - simple python version management

Create a sandbox:

pyenv virtualenv -p python2.7 2.7.16 my_project-with-2.7.16
or
pyenv virtualenv 2.7.16 my_project-with-2.7.16
See the list of sandboxes:
pyenv virtualenvs
I set the versions I need:
pyenv local my_project-with-2.7.16 3.5.7
Check Python version:
python -V
Look where is the Python:
which python
and
pyenv which python

installation of PyEnv to linux - simple python version management

To see a list of available commands, you can use:

pyenv commands
Get help:
pyenv --help
Or, for some specific command:
pyenv activate --help

Activate the created sandbox use:

pyenv activate my_project-with-2.7.16
To deactivate:
pyenv deactivate
To remove the Python version from the OS, use:
pyenv uninstall 2.7.16
Updating pyenv:
pyenv update
You can learn more on the page Commands

Remove from Linux Mint:
run

rm -rf $PYENV_ROOT
or
rm -fr ~/.pyenv
Open ~/.bashrc
xed ~/.bashrc
delete the previously added lines
export PATH=”$HOME/.pyenv/bin:$PATH”eval “$(pyenv init -)”eval “$(pyenv virtualenv-init -)”
restart shell
exec $SHELL
DONE!
May the Force be with you,
Good Luck!!!
pyenv

The site has moved to a new engine, help me fix bugs, send me your notify by selecting that text and pressing Ctrl+Enter.

Share to friends
Shekin
Rate author
( No ratings yet )
MintGuide.Org

Leave a Reply

avatar
  Subscribe  
Notify of

Spelling error report

The following text will be sent to our editors: