I was using a MacBook Pro for my developing in a long time. Recently I decided to do something on my desktop. I installed Debian 11 and tried to setup my website developing environment which uses Pelican. Things are a little diferent from using it on macOS. Let's check out.
First Debian's official repositories don't contain pyenv. So I have to clone the git repository and install it manually.
# using automatic installer.
curl https://pyenv.run | bash
# or clone it manually
git clone https://github.com/pyenv/pyenv.git ~/.pyenv
Copy the following to ~/.bashrc
. Setup the shell environment and then restart the shell.
# pyenv
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
Now I can use pyenv now. But when I tried to use pip3 to install dependencies, the system was keeping calling the pip from the system version of python3, not the pyenv one.
Here we need a plugin called pyenv-virtualenv. Add the following to ~/.bashrc
to setup pyenv-virtualenv.
eval "$(pyenv virtualenv-init -)"
All setup done. We can use pyenv and virtualenv now.