11. Managing programming environments#
11.1. Installing pyenv#
$ git clone https://github.com/pyenv/pyenv.git ./.pyenv
$ echo -e "export PATH=\"\$HOME/.pyenv/bin:\$PATH\"\neval \"\$(pyenv init --path)\"\n" > start-pyenv
$ chmod +x start-pyenv
11.2. Starting pyenv#
$ cd ~
$ source ./start-pyenv
11.3. Listing available python systems#
$ pyenv install --list
11.4. Installing a python system#
The following example installs CPython version 3.9.16
$ pyenv install 3.9.16
11.5. Listing installed python systems#
$ pyenv versions
11.6. Changing the selected python system#
In the following example, the working python system is set to CPython version 3.9.16
$ pyenv global 3.9.1
11.7. Using the currently selected python system#
$ python
11.8. Virtual python environments#
The following assumes you have installed and started pyenv
11.8.1. Creating a new environment#
$ mkdir project-1
$ cd project-1
$ python -m venv env
11.8.2. Starting an existing environment#
$ cd project-1
$ source ./env/bin/activate
11.8.3. Stop a running environment#
$ deactivate
11.8.4. Removing an environment#
$ rm -rf project-1