You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
sudo su
curl https://pyenv.run | bash
# Load pyenv automatically by adding# the following to ~/.bashrc:export PATH="/root/.pyenv/bin:$PATH"eval"$(pyenv init -)"eval"$(pyenv virtualenv-init -)"
Install build tools to be able to build python
sudo apt 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 manpages-dev
# In some cases you may need to install libreadline-dev again
sudo apt install libreadline-dev
# When building python 2
sudo apt-get install python-tk
sudo apt install python3-pkgconfig
Install a python version for the current user
# Install the needed python version first for pyenv (will build python)
pyenv install -v 2.7.18
# Create a new virtual environment with pyenv
pyenv virtualenv 2.7.18 myvenv
pyenv activate myvenv
# Attention: sometimes this will not work! check with which python2 and which pip# if it dies not work you need to manualy activate the venv:source /root/.pyenv/versions/2.7.18/envs/myenv/bin/activate
# Deactivate the virtualenv again
pyenv deavtivate
# This will create a new python env at# /root/.pyenv/versions/2.7.18/envs/# HINT: pyenv-virtualenv: prompt changing will be removed from future release. configure `export PYENV_VIRTUALENV_DISABLE_PROMPT=1' to simulate the behavior.
Install a python version for all user with pyenv tool python-build
/root/.pyenv/plugins/python-build/bin/python-build 2.7.10 /usr/local/python-2.7.10/
# Create a virtual env without pyenv
virtualenv -p /usr/local/python-2.7.10/bin/python /opt/online/venv_python-2.7.10
# Activate the venvsource /opt/online/venv_python-2.7.10/bin/activate
# Upgrade pip and setuptools in the venv
pip install pip --upgrade
pip install setuptools --upgrade
# Install python libs by requirements.txt
pip install -r /root/requirements.txt
# Deactivate the venv
deactivate
which python
python -V
pip -V
pyenv which python
pyenv versions
# Install
pyenv install --list
pyenv install 2.7.10
ls ~/.pyenv/versions/
# Uninstall
pyenv uninstall 2.7.15 # ist the same as: rm -rf ~/.pyenv/versions/2.7.15# Activate for current user
pyenv local 2.7.15
pyenv shell 2.7.15
# Go back to the system python
pyenv local system
pyenv shell system
Are you using this setup in production? On daily bases?
The restrictions on pip package installation after 3.12 seems to push users towards your approach without the option of breaking system packages.
It would be a nice and clean way to use Pyenv to install packages that require root privileges.
Are you using this setup in production? On daily bases?
The restrictions on pip package installation after 3.12 seems to push users towards your approach without the option of breaking system packages.
It would be a nice and clean way to use Pyenv to install packages that require root privileges.