24
loading...
This website collects cookies to deliver better user experience
sudo apt-get update
sudo apt-get install aria2 build-essential curl git libbz2-dev libffi-dev liblzma-dev libncurses5-dev libncursesw5-dev libreadline-dev libsqlite3-dev libssl-dev llvm make tk-dev wget xz-utils zlib1g-dev --yes;
curl -L https://github.com/pyenv/pyenv-installer/raw/master/bin/pyenv-installer | bash
git clone https://github.com/pyenv/pyenv-virtualenvwrapper.git "${HOME}/.pyenv/plugins/pyenv-virtualenvwrapper"
#### pyenv config
if [ -f "$HOME/.pyenv/bin/pyenv" ] && ! type -P pyenv &>/dev/null ; then
export PYTHON_CONFIGURE_OPTS="--enable-shared"
export CFLAGS="-O2"
export PYTHON_BUILD_ARIA2_OPTS="-x 10 -k 1M"
export PYENV_ROOT="${HOME}/.pyenv"
export PATH="${PYENV_ROOT}/bin:${PATH}"
eval "$(pyenv init --path)"
eval "$(pyenv init -)"
eval "$(pyenv virtualenv-init -)"
if [[ ! "$(pyenv which python)" == "/usr/bin/python" ]] ; then
pyenv virtualenvwrapper_lazy;
fi
fi
pyenv install -l
pyenv versions
pyenv install <version>
Eg:- pyenv install 3.9.6
pyenv global 3.10.0 3.9.6 3.8.11 3.7.11 3.6.14 2.7.18
python3.9 -m pip install virtualenv virtualenvwrapper
A Virtual Environment enables us to keep the dependencies required by different projects in separate places, by creating virtual Python environments.
In other words, virtualenv is a tool to create isolated Python environments. The virtualenv creates a folder which contains all the necessary executables to use the packages that a Python project would need.
#Creates a virtual env with default Python version
mkvirtualenv myenv
#Creates a virtual env with specified Python version 3.8 for the below case:
mkvirtualenv -p python3.10 myenv
#Mark the current directory as the virtualenv-linked Project Directory to automatically go to the Project Directory when activating it.
mkvirtualenv -p python3.10 -a $(pwd) myenv2
deactivate
workon <name of virtual env>
E.g workon myenv