Skip to content

Instantly share code, notes, and snippets.

@rodrigomelo9
Last active September 1, 2021 00:45
Show Gist options
  • Save rodrigomelo9/6efa56880279d4789c7947956d98422c to your computer and use it in GitHub Desktop.
Save rodrigomelo9/6efa56880279d4789c7947956d98422c to your computer and use it in GitHub Desktop.

Pyenv notes

Mainly a summary from Managing Multiple Python Versions With pyenv

Installation

In a Debian based systems, as root:

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

In your home, as user:

$ curl https://pyenv.run | bash

Add to the end of your ~/.bashrc:

export PATH="$HOME/.pyenv/bin:$PATH"
eval "$(pyenv init -)"
eval "$(pyenv virtualenv-init -)"

Reload your shell (or restart your terminal):

exec "$SHELL"

Install a Python version

To check the available versions, run:

pyenv install --list

If you’ve been using pyenv for a while and don’t see the version you’re looking for, you may need to run pyenv update.

To install the desidered VERSION:

pyenv install -v VERSION

This will take a while because pyenv is building Python from source.

To check that the version of Python is working properly, you can run the built-in test suite python -m test

Changing to Python VERSION

Check the installed versions:

pyenv versions

Select which VERSION to use globally:

pyenv global VERSION

Select which VERSION to use locally (to a project):

pyenv local VERSION

Select which VERSION to use in the current shell:

pyenv shell VERSION

Pyenv commands

You can see a complete list of all available commands with:

pyenv commands

If you wanted to see more information on a COMMAND you could run:

pyenv COMMAND --help

Uninstall a Python version

Each version that you have installed is located in your pyenv root directory (ls ~/.pyenv/versions/)

You can remove (rm -fr) the directory of a particular VERSION or run:

pyenv uninstall VERSION

Enable shared

If you need a Python version with --enable-shared (cocotb), which Pyenv doesn’t use by default:

$ PYTHON_CONFIGURE_OPTS="--enable-shared" pyenv install -v VERSION
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment