skip to Main Content

When I write pyenv It says

Command 'pyenv' not found, did you mean:
command 'p7env' from deb libnss3-tools
Try: sudo apt install <deb name>

I know this is very common and it is something with the path. I have tried everything in all different files such as bashrc, bash_profile, zshrc etc. What I currently have is in my "bashrc" file:

export PATH="~/.pyenv/bin:$PATH"
eval "$(pyenv init -)"
eval "$(pyenv virtualenv-init -)"

When I write bash and then reload the terminal it works, but I cannot change the python version.

I am using a Linux Debian distribution and pyenv version 1.2.27

2

Answers


  1. Bash sources ~/.bashrc only for interactive non-login shells. So, in an interactive login shell, before you type bash to open an interactive non-login shell, your ~/.bashrc file will not have been sourced yet. You can fix this by adding the following to your ~/.bash_profile file:

    if [[ -r ~/.bashrc ]]; then 
      . ~/.bashrc
    fi
    
    Login or Signup to reply.
  2. For me, it worked like that (in the end of .bashrc):

    export PYENV_ROOT="$HOME/.pyenv"
    export PATH="$HOME/.pyenv/bin:$PATH"
    eval "$(pyenv init -)"
    eval "$(pyenv virtualenv-init -)"
    eval "$(pyenv init --path)"
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search