question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

pipenv doesn't find correct python version on $PATH without pyenv

See original GitHub issue

This is related to https://github.com/pypa/pipenv/issues/729 but I think I’ve found a different cause. When multiple versions of python 3 are installed on $PATH and pyenv is not available, then pipenv will only look at /usr/bin/python3 and not more explicit versions of python3 like /usr/bin/python3.6 even if python_version declares 3.6 as the target.

We’re using pipenv on our build server (jenkins) and haven’t quite figured out how to get pyenv working with jenkins pipelines yet.

Describe your environment
  1. OS Type: Ubuntu 16.04
  2. Python versions:
jenkins@jenkin:~/workspace$ /usr/bin/python3 --version
Python 3.5.2
jenkins@jenkins:~/workspace$ /usr/bin/python3.5 --version
Python 3.5.2
jenkins@jenkins:~/workspace$ /usr/bin/python3.6 --version
Python 3.6.3
  1. Pipenv version: 9.0.3
Expected result

Virtualenv should be created using /usr/bin/python3.6 if it’s available on $PATH

Actual result
$ pipenv install --dev --three --verbose
Creating a virtualenv for this project…
Using /usr/bin/python3 to create virtualenv…
⠋Running virtualenv with interpreter /usr/bin/python3
Using base prefix '/usr'
New python executable in /var/lib/jenkins/.local/share/virtualenvs/venvnamehere/bin/python3
Also creating executable in /var/lib/jenkins/.local/share/virtualenvsvenvnamehere/bin/python
Installing setuptools, pip, wheel...done.

Virtualenv location: /var/lib/jenkins/.local/share/virtualenvs/venvnamehere

Warning: Your Pipfile requires python_version 3.6, but you are using 3.5.2 (/var/lib/j/.local/share/v/r/bin/python)
Files

Pipfile:

[[source]]

url = "https://pypi.python.org/simple"
verify_ssl = true
name = "pypi"


[dev-packages]

"flake8" = "*"
isort = "*"
werkzeug = "*"
pyopenssl = "*"
factory-boy = "<3.0,>=2.9"
"flake8-isort" = "*"
"flake8-builtins" = "*"
"flake8-comprehensions" = "*"
ipdb = "*"
responses = "*"


[packages]

django = ">=1.11.0,<2.0.0"
wagtail = "<1.14,>=1.13"
dj-database-url = "*"
gunicorn = "*"
"psycopg2" = "*"
whitenoise = "*"
raven = "*"
django-extensions = "*"
xmltodict = "*"
django-cloudinary-storage = "*"
newrelic = "*"
pygments = "<2.3.0,>=2.2.0"
django-fsm = "<3.0,>=2.5"
django-debug-toolbar = "*"


[requires]

python_version = "3.6"

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:3
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

3reactions
uranusjrcommented, Feb 6, 2018

The current rule works like this (if pyenv is not present):

  1. --three is essentially a shorthand for --python=3 (and --two is --python=2).
  2. If --python=X is specified, look for python{X} in PATH (if X looks like a version number).
  3. Otherwise, if requires.python_version = Y look for python{Y} in PATH.
  4. Otherwise use whatever Python Pipenv is on (sys.executable).

The logic is relatively straightforward by itself IMO, but not really what users would expect.

0reactions
jarshwahcommented, Feb 5, 2018

I think having --three and --python and requires.python_version all being independent confusing. Would a docs update to the requires.python_version or --three be welcome to explain the precedence and actual behaviour?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Pipenv not recognizing Pyenv version? - python - Stack Overflow
Pipenv is aware of Pyenv, but it doesn't automatically use the same Python version unless you tell it to do that. There is...
Read more >
Frequently Encountered Pipenv Problems - Read the Docs
☤ My pyenv-installed Python is not found¶ ... Make sure you have PYENV_ROOT set correctly. Pipenv only supports CPython distributions, with version name...
Read more >
pipenv Documentation - Read the Docs
Automatically install required Python version when pyenv is available. • Automatically finds your project home, recursively, by looking for a Pipfile. • ...
Read more >
Pyenv and Pipenv (on MacOS) – Index - Wilson Mar
This tutorial describes the different options to install, uninstall, configure, and use various versions of Python with its various packages ...
Read more >
How to install pyenv+pipenv in ubuntu and use multiple ...
Let pyenv and pipenv help you write python better ... In addition, the board owner does not recommend using the pyenv local <python-version>...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found