sudo apt install -y git openssl libssl-dev \
libbz2-dev libreadline-dev libsqlite3-dev \
libffi-dev liblzma-dev
use pyenv-installer script to make our live a lil' bit easier.
curl https://pyenv.run | bash
edit your ~/.bashrc, add this 3 lines at the end of the file. what it does? this 3 lines is going to add pyenv executable to the environment PATH of the shell session and to enable autocomplete function
restart the shell session by reopening the terminal session or reload the session using this command
source ~/.bashrcinstall any python version you wanted, use this command to list all available python versions
pyenv install -l
i.e. installing python version 3.10.
pyenv install 3.10.5
it's always a good idea to create individual venv for each of your projects, i.e. making a venv named project1 based of python 3.10.5
pyenv virtualenv 3.10.5 project1
activate the venv for this shell session
pyenv shell project1
to confirm which version of the venv currently active
pyenv version
you can make the shell automagically enabled for when changing directory to specific projects folder.
cd ~/project_folder
pyenv local project1
or just enable it globally
pyenv global project1
No comments:
Post a Comment