Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Binary path of python installed by pyenv is not properly got in some cases #31

Closed
jxltom opened this issue Nov 5, 2018 · 0 comments · Fixed by #32
Closed

Binary path of python installed by pyenv is not properly got in some cases #31

jxltom opened this issue Nov 5, 2018 · 0 comments · Fixed by #32

Comments

@jxltom
Copy link
Collaborator

jxltom commented Nov 5, 2018

Pyenv will install python to ~/.pyenv/versions/some_version/bin. The binary directory is got by

bin_ = sysconfig._INSTALL_SCHEMES[sysconfig._get_default_scheme()]["scripts"]
.

Normally, sysconfig._get_default_scheme() will return {base}/bin which then help us getting the right pyenv python location.

However, in my local ubuntu 16.04 (probably it is because I'm using system built-in python version) and also in windows subsystem for linux, sysconfig._get_default_scheme() returns {base}/local/bin which makes getting pyenv python location as ~/.pyenv/versions/some_version/local/bin. This path does not exist apparently.

This make latest pipenv can not find the pyenv python version and raise following error.

➜  test pipenv --python 3.6.3
Traceback (most recent call last):
  File "/usr/local/bin/pipenv", line 11, in <module>
    load_entry_point('pipenv', 'console_scripts', 'pipenv')()
  File "/home/user/Documents/dev/pipenv/pipenv/vendor/click/core.py", line 764, in __call__
    return self.main(*args, **kwargs)
  File "/home/user/Documents/dev/pipenv/pipenv/vendor/click/core.py", line 717, in main
    rv = self.invoke(ctx)
  File "/home/user/Documents/dev/pipenv/pipenv/vendor/click/core.py", line 1114, in invoke
    return Command.invoke(self, ctx)
  File "/home/user/Documents/dev/pipenv/pipenv/vendor/click/core.py", line 956, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/user/Documents/dev/pipenv/pipenv/vendor/click/core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "/home/user/Documents/dev/pipenv/pipenv/vendor/click/decorators.py", line 64, in new_func
    return ctx.invoke(f, obj, *args, **kwargs)
  File "/home/user/Documents/dev/pipenv/pipenv/vendor/click/core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "/home/user/Documents/dev/pipenv/pipenv/vendor/click/decorators.py", line 17, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/home/user/Documents/dev/pipenv/pipenv/cli/command.py", line 203, in cli
    clear=state.clear,
  File "/home/user/Documents/dev/pipenv/pipenv/core.py", line 595, in ensure_project
    pypi_mirror=pypi_mirror,
  File "/home/user/Documents/dev/pipenv/pipenv/core.py", line 537, in ensure_virtualenv
    ensure_python(three=three, python=python)
  File "/home/user/Documents/dev/pipenv/pipenv/core.py", line 421, in ensure_python
    path_to_python = find_a_system_python(python)
  File "/home/user/Documents/dev/pipenv/pipenv/core.py", line 384, in find_a_system_python
    python_entry = finder.find_python_version(line)
  File "/home/user/Documents/dev/pipenv/pipenv/vendor/backports/functools_lru_cache.py", line 137, in wrapper
    result = user_function(*args, **kwds)
  File "/home/user/Documents/dev/pipenv/pipenv/vendor/pythonfinder/pythonfinder.py", line 112, in find_python_version
    return self.system_path.find_python_version(
  File "/home/user/Documents/dev/pipenv/pipenv/vendor/pythonfinder/pythonfinder.py", line 53, in system_path
    ignore_unsupported=self.ignore_unsupported,
  File "/home/user/Documents/dev/pipenv/pipenv/vendor/pythonfinder/models/path.py", line 395, in create
    ignore_unsupported=ignore_unsupported,
  File "<attrs generated init 8b5e681b06af133646fcafad5a215f2a935c5776>", line 37, in __init__
  File "/home/user/Documents/dev/pipenv/pipenv/vendor/pythonfinder/models/path.py", line 107, in __attrs_post_init__
    self._setup_pyenv()
  File "/home/user/Documents/dev/pipenv/pipenv/vendor/pythonfinder/models/path.py", line 139, in _setup_pyenv
    root=PYENV_ROOT, ignore_unsupported=self.ignore_unsupported
  File "/home/user/Documents/dev/pipenv/pipenv/vendor/pythonfinder/models/pyenv.py", line 128, in create
    return cls(root=root, ignore_unsupported=ignore_unsupported)
  File "<attrs generated init ad2b651619e57cf5a5c544e22e7f046f4487c68e>", line 19, in __init__
  File "/home/user/Documents/dev/pipenv/pipenv/vendor/pythonfinder/models/pyenv.py", line 122, in get_pythons
    pythons.update(p.pythons)
AttributeError: 'NoneType' object has no attribute 'pythons'

How about let's pin the _get_default_scheme to posix_prefix?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant