pyenv: version system not installed

Created on 15 Mar 2019  路  3Comments  路  Source: pyenv/pyenv

Prerequisite

There is a closed issue, but it was closed without explanation or resolution: https://github.com/pyenv/pyenv/issues/622

  • [x] Make sure you are not asking us to help solving your specific issue.

    • GitHub issues is opened mainly for development purposes. If you want to ask someone to help solving your problem, go to some community site like Gitter, StackOverflow, etc.

  • [x] Make sure your problem is not derived from packaging (e.g. Homebrew).

    • Please refer to the package documentation for the installation issues, etc.

  • [x] Make sure your problem is not derived from plugins.

    • This repository is maintaining pyenv and the default python-build plugin only. Please refrain from reporting issues of other plugins here.

Description

  • [x] Platform information (e.g. Ubuntu Linux 16.04): Arch Linux
  • [x] OS architecture (e.g. amd64): Intel64
  • [x] pyenv version: pyenv-1.2.9-1
  • [x] Python version: 3.7.2
  • [x] C Compiler information (e.g. gcc 7.3): 8.2.1 20181127
  • [x] Please attach verbose build log as gist : N/A to this issue

I believe my issue is identical to a closed issue, but the issue was closed without explanation, reason, or resolution: https://github.com/pyenv/pyenv/issues/622

On a fresh install of Arch and Pyenv:

  >python --version
       Python 3.7.2
  > /usr/sbin/python          
      Python 3.7.2 (default, Jan 10 2019, 23:51:51)
      [GCC 8.2.1 20181127] on linux
      Type "help", "copyright", "credits" or "license" for more information.
  >pyenv versions  
       * system (set by /home/tommy/.pyenv/version)
  >pyenv global system   
        pyenv: version `system' not installed

why?

bug

Most helpful comment

Pyenv assume that the parent directory of python executable is always named as bin.
https://github.com/pyenv/pyenv/blob/7097f8204e26c63a6ae9699255caa75e7c3ef084/libexec/pyenv-prefix#L34

Walkaround is to place /usr/bin ahead of /usr/sbin . I add the following lines to my .zshrc.

if command -v pyenv 1>/dev/null 2>&1; then
  eval "$(pyenv init -)"
  eval "$(pyenv virtualenv-init -)"
  if ! pyenv prefix system 1>/dev/null 2>&1; then
    typeset -U PATH path
    local usr_sbin_index=${path[(ie)/usr/sbin]}
    local usr_bin_index=${path[(ie)/usr/bin]}
    if [ ${usr_sbin_index} -lt ${usr_bin_index]} ]; then
      echo "Reorder path because the pyenv bug"
      echo "https://github.com/pyenv/pyenv/issues/1301"
      path[${usr_sbin_index}]="/usr/bin"
      path[${usr_bin_index}]="/usr/sbin"
      export PATH
    fi
  fi
fi

Maybe it can be fix with place a question symbol ? before bin? @chrahunt

PYENV_PREFIX_PATH="${PYTHON_PATH%/?bin/*}"

All 3 comments

Same here...
Is there a workaround for switching to system until the bug is fixed?

EDIT

I've switched to an anaconda version and now I cannot switch back to the system version. I cannot open Calibre and i3 status bar shows an error because of this issue. Please provide a workaround or fix the bug.

EDIT 2

In .pyenv/versionI've replaced the current python version with system and now I can open Calibre and my i3 status bar looks normal again.

Pyenv assume that the parent directory of python executable is always named as bin.
https://github.com/pyenv/pyenv/blob/7097f8204e26c63a6ae9699255caa75e7c3ef084/libexec/pyenv-prefix#L34

Walkaround is to place /usr/bin ahead of /usr/sbin . I add the following lines to my .zshrc.

if command -v pyenv 1>/dev/null 2>&1; then
  eval "$(pyenv init -)"
  eval "$(pyenv virtualenv-init -)"
  if ! pyenv prefix system 1>/dev/null 2>&1; then
    typeset -U PATH path
    local usr_sbin_index=${path[(ie)/usr/sbin]}
    local usr_bin_index=${path[(ie)/usr/bin]}
    if [ ${usr_sbin_index} -lt ${usr_bin_index]} ]; then
      echo "Reorder path because the pyenv bug"
      echo "https://github.com/pyenv/pyenv/issues/1301"
      path[${usr_sbin_index}]="/usr/bin"
      path[${usr_bin_index}]="/usr/sbin"
      export PATH
    fi
  fi
fi

Maybe it can be fix with place a question symbol ? before bin? @chrahunt

PYENV_PREFIX_PATH="${PYTHON_PATH%/?bin/*}"

I put this in my .zshrc/.bashrc to fix this. It just puts all path entries ending in sbin at the end of PATH.

# move all paths ending in 'sbin' to the back of PATH
# This is needed because pyenv fails to find the system python otherwise
for SB in $(echo "$PATH" | grep ':*/[^:]*sbin' -o)
do
  export PATH="${PATH/$SB}:${SB#:}"
done
Was this page helpful?
0 / 5 - 0 ratings

Related issues

tell-k picture tell-k  路  3Comments

zeroxenator picture zeroxenator  路  3Comments

decentral1se picture decentral1se  路  3Comments

demba picture demba  路  3Comments

ipfans picture ipfans  路  3Comments