Pyenv Installation Instructions
If you aren’t running a suitable python version currently on your system, we recommend you to install the required python version inside of an virtual environment for python (pyenv) and to install all python packages necessary to use this repo afterwards inside a newly created virtual environment (virtualenv). The installation procedure for Ubuntu (18.04.5 and 20.04.2.0 LTS) are described in the next section. You can find instructions for MacOS and other Linux distributions, as well as information about common build problems here:
virtualenv: https://github.com/pyenv/pyenv-virtualenv
Instructions for Ubuntu (18.04.5 and 20.04.2.0 LTS)
The instructions provide assistance in the setup procedure, but with regards to the software LICENSE they are provided without warranty of any kind. In no event shall the authors or copyright holders be liable for any claim, damages or other liability, arising from, out of or in connection with the software or the use or other dealings in the software.
Clone this repo from GitHub, in case you haven’t done it yet:
git clone git@github.com:dfki-ric-underactuated-lab/torque_limited_simple_pendulum.git
Check your Python version with:
python3 --version
If you are already using suitable Python 3.6 version jump directly to step Creating a Virtual Environment otherwise continue here and first install a virtual environment for python.
Pyenv: Virtual environment for Python
The following instructions are our recommendations for a sane build environment.
Make sure to have installed python’s binary dependencies and build tools as per:
sudo apt-get update sudo apt-get install make build-essential libssl-dev zlib1g-dev libbz2-dev libreadline-dev libsqlite3-dev wget curl llvm libncursesw5-dev xz-utils tk-dev libxml2-dev libxmlsec1-dev libffi-dev liblzma-dev
Once prerequisites have been installed correctly, install Pyenv with:
curl https://pyenv.run | bash
Configure your shell’s environment for Pyenv
Note
The below instructions are designed for common shell setups. If you have an uncommon setup and they don’t work for you, use the linked guidance to figure out what you need to do in your specific case: https://github.com/pyenv/pyenv#advanced-configuration
Before editing your .bashrc and .profile files it is a good idea to <ins>make a copy</ins> of both files in case something goes wrong. Add pyenv to your .bashrc file from the terminal:
echo 'eval "$(pyenv init -)"' >> ~/.bashrc
Add these lines at the beginning of your .profile file (not from the terminal):
export PYENV_ROOT="$HOME/.pyenv" export PATH="$PYENV_ROOT/bin:$PATH"
and this line at the very end of your .profile file (not from the terminal):
eval "$(pyenv init --path)"
Source .profile and .bashrc, then restart your shell so the path changes take effect:
source ~/.profile source ~/.bashrc exec $SHELL
Run pyenv init - in your shell, then copy and also execute the output to enable shims:
pyenv init -
Restart your login session for the changes to take effect. If you’re in a GUI session, you need to fully log out and log back in. You can now begin using pyenv.
Note
Consider uprading to the latest version of Pyenv via:
pyenv update
Installing Python into Pyenv
You can diplay a list of available Python versions with:
pyenv install -l | grep -ow [0-9].[0-9].[0-9]
Install your desired Python version using Pyenv (We suggest 3.6.9 for ubuntu 18.04 and 3.8.10 for ubuntu 20.04):
pyenv install 3.x.x
Double check your work:
pyenv versions
To use Python 3.x only for this specific project change directory to the cloned git repo and type:
pyenv local 3.x.x
Creating a Virtual Environment with Pyenv
In order to clutter your system as little as possible all further packages will be installed inside a virtual environment, which can be easily removed at any time. The recommended way to configure your own custom Python environment is via Virtualenv.
Clone virtualenv from https://github.com/pyenv/pyenv-virtualenv into the pyenv-plugin directory:
git clone https://github.com/pyenv/pyenv-virtualenv.git $(pyenv root)/plugins/pyenv-virtualenv
Add pyenv virtualenv-init to your shell to enable auto-activation of virtualenvs:
echo 'eval "$(pyenv virtualenv-init -)"' >> ~/.bashrc
Restart your shell to enable pyenv-virtualenv:
exec "$SHELL"
To create a new virtual environment, e.g. named simple-pendulum with Python 3.6.9 run:
pyenv virtualenv 3.6.9 simple-pendulum
Activate the new virtual environment with the command:
pyenv activate simple-pendulum
The name of the current virtual environment (venv) appears to the left of the prompt, indicating that you are now working inside a virtual environment. When finished working in the virtual environment, you can deactivate it by running the following:
pyenv deactivate
In case that you don’t need the virtual environment anymore, you can deactivate it and remove it together with all previously installed packages:
pyenv uninstall simple-pendulum
Installing pip3
Update the package list inside your recently created virtual environment:
sudo apt update
and install pip3 via:
sudo apt install python3-pip
If you like, you can update pip and verify your the installation by:
pip install --upgrade pip
pip3 --version