Search code examples
pythonbashpyenv

pyenv modifies my prompt for versions with words but not the purely numbered ones


The following lines were added to my .bashrc :

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

The following lines in the terminal illustrates the problem:

cardamom@neptune ~ $ mkdir testDirectory
cardamom@neptune ~ $ cd testDirectory
cardamom@neptune ~/testDirectory $ pyenv versions
* system (set by /home/felix/.pyenv/version)
  3.4.3
  3.5.0
  project1
  miniconda2-latest
  miniconda3-latest
  miniconda3-latest/envs/project1
cardamom@neptune ~/testDirectory $ pyenv local miniconda3-latest
(miniconda3-latest) cardamom@neptune ~/testDirectory $ pyenv local miniconda2-latest
(miniconda2-latest) cardamom@neptune ~/testDirectory $ pyenv local 3.4.3
cardamom@neptune ~/testDirectory $ python --version
Python 3.4.3
cardamom@neptune ~/testDirectory $

Does anyone know what is wrong and how to fix it?


Solution

  • Because miniconda3-latest is a virtual environment, and 3.4.3 is just a different Python version.

    pyenv, which is used to change current active Python version, isn't changing commandline prompt in any way, but pyenv-virtualenv plugin does.

    There is nothing wrong with it, it's just virtualenvs get special treatment in this situation.