A simple guide of using pyenv on Linux

Published: 25 March 2023 in Technique by Alan linux pyenv python pip

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.

SSH Issue with 1Password

Published: 04 January 2023 in Technique by Alan ssh 1password

If you have some ssh keys before you use the 1Password SSH agent, you might get the issue of asking the ssh key password when you use the existing ssh key. That's because 1Password modifies the ssh config file.

# This is what the config file is after enabling the 1Password agent.
Host *
    IdentityAgent "{1Password_path}/agent.sock"

To fix this issue, add your existing ssh key into the config file.

Host {your_existing_ssh_server}
    IdentityAgent {your_existing_ssh_key_path}

Host *
    IdentityAgent "{1Password_path}/agent.sock"


Powered by Pelican

Hosted on

Get $100 credit for your first first order!