Fast python dev env

Here no custom vim or emacs , we need to be fast. 

python env

First let’s install some package on you whatever linux distribution.

sudo apt install python3 pyton3-venv git build-essential zlib1g-dev libffi-dev libssl-dev libbz2-dev libreadline-dev libsqlite3-dev liblzma-dev -y 

you may also need pyenv:

git clone https://github.com/pyenv/pyenv.git ~/.pyenv

And add this to your .bashrcfile :

echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.bashrc
echo 'command -v pyenv >/dev/null || export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bashrc
echo 'eval "$(pyenv init -)"' >> ~/.bashrc

Stop here and run this quick test:

max@tkp:~$  pyenv versions
* system (set by /home/max/.pyenv/version)

Now let’s add virtual env support : https://github.com/pyenv/pyenv-virtualenv

git clone https://github.com/pyenv/pyenv-virtualenv.git $(pyenv root)/plugins/pyenv-virtualenv

for auto enable venv add this to your bashrc

echo 'eval "$(pyenv virtualenv-init -)"' >> ~/.bashrc

and install the latest ( april 2023) python version ( go grab a ☕, cause it can take a while)

max@tkp:~$ pyenv install 3.11.1
Downloading Python-3.11.1.tar.xz...
-> https://www.python.org/ftp/python/3.11.1/Python-3.11.1.tar.xz
[....]
Successfully installed pip-22.3.1 setuptools-65.5.0

Great, now you can easily create virtualenv

max@tkp:~/test_me$ pyenv virtualenv 3.11.1 max
max@tkp:~/test_me$ pyenv local max
(max) max@tkp:~/test_me$ 
(max) max@tkp:~/test_me$ python3 --version
Python 3.11.1

Enjoy