pipenv doesn't find correct python version on $PATH without pyenv
See original GitHub issueThis 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
- OS Type: Ubuntu 16.04
- 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
- 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:
- Created 6 years ago
- Reactions:3
- Comments:6 (4 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
The current rule works like this (if pyenv is not present):
--three
is essentially a shorthand for--python=3
(and--two
is--python=2
).--python=X
is specified, look forpython{X}
in PATH (ifX
looks like a version number).requires.python_version = Y
look forpython{Y}
in PATH.sys.executable
).The logic is relatively straightforward by itself IMO, but not really what users would expect.
I think having
--three
and--python
andrequires.python_version
all being independent confusing. Would a docs update to therequires.python_version
or--three
be welcome to explain the precedence and actual behaviour?