Previously we could use a version of python installed via pyenv simply by setting the PYENV_HOME environment variable.
I started noticing this morning that builds were failing because pipenv was using the wrong version:
export PYENV_ROOT="~/.pyenv"
export PIPENV_VENV_IN_PROJECT="1"
$ pipenv install --dev
Warning: Your Pipfile requires python_version 3.7.0, but you are using 2.7.12 (/data/j/w/d/.venv/bin/python).
$ pipenv --rm and rebuilding the virtual environment may resolve the issue.
$ pipenv check will surely fail.
It is then running inside python2 (and crashing as such).
The version is successfully installed and can be found using the shims.
$ ${PYENV_ROOT}/bin/pyenv versions
* system (set by /data/jenkins/.pyenv/version)
2.7.12
3.6.4
3.7.0
$ PYENV_VERSION=3.7.0 ${PYENV_ROOT}/shims/python --version
Python 3.7.0
Pipenv should find the version installed by pyenv without any additional environment parameters
Pipenv did not find the pyenv installed with the PYENV_ROOT environment variable set.
We were able to work around the issue by adding pyenv to PATH explicitly:
$ PATH="${PYENV_ROOT}/bin:${PATH}" pipenv install --dev
Installing dependencies from Pipfile.lock (104e24)โฆ
๐ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ 46/46 โ 00:00:31
To activate this project's virtualenv, run pipenv shell.
Alternatively, run a command inside the virtualenv with pipenv run.
This was not previously required, however, and the documentation still claims that PYENV_ROOT is all that is needed.
export PYENV_ROOT="~/.pyenv"
${PYENV_ROOT}/bin/pyenv update && ${PYENV_ROOT}/bin/pyenv install 3.7.0
[requires]
python_version = "3.7.0"
Notice that it warns that 3.7.0 was not found and will use the system python instead.
$ pipenv --support
<details><summary>$ pipenv --support</summary>
Pipenv version: `'2018.10.13'`
Pipenv location: `'/usr/local/lib/python2.7/dist-packages/pipenv'`
Python location: `'/usr/bin/python'`
Python installations found:
Traceback (most recent call last):
File "/usr/local/bin/pipenv", line 11, in <module>
sys.exit(cli())
File "/usr/local/lib/python2.7/dist-packages/pipenv/vendor/click/core.py", line 764, in __call__
return self.main(*args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/pipenv/vendor/click/core.py", line 717, in main
rv = self.invoke(ctx)
File "/usr/local/lib/python2.7/dist-packages/pipenv/vendor/click/core.py", line 1114, in invoke
return Command.invoke(self, ctx)
File "/usr/local/lib/python2.7/dist-packages/pipenv/vendor/click/core.py", line 956, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/usr/local/lib/python2.7/dist-packages/pipenv/vendor/click/core.py", line 555, in invoke
return callback(*args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/pipenv/vendor/click/decorators.py", line 64, in new_func
return ctx.invoke(f, obj, *args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/pipenv/vendor/click/core.py", line 555, in invoke
return callback(*args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/pipenv/vendor/click/decorators.py", line 17, in new_func
return f(get_current_context(), *args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/pipenv/cli/command.py", line 142, in cli
get_pipenv_diagnostics()
File "/usr/local/lib/python2.7/dist-packages/pipenv/help.py", line 33, in get_pipenv_diagnostics
python_paths = finder.find_all_python_versions()
File "/usr/local/lib/python2.7/dist-packages/pipenv/vendor/pythonfinder/pythonfinder.py", line 112, in find_all_python_versions
major=major, minor=minor, patch=patch, pre=pre, dev=dev, arch=arch
File "/usr/local/lib/python2.7/dist-packages/pipenv/vendor/pythonfinder/models/path.py", line 222, in find_all_python_versions
return [c for c in sorted(path_filter, key=version_sort, reverse=True)]
AttributeError: 'list' object has no attribute 'as_python'
I am also experiencing the same issue with:
pyenv 1.2.8
pipenv, version 2018.10.13
macOS Mojave
Specifying the version explicitly with pipenv solved my issue
pipenv install --python ~/.pyenv/versions/3.5.6/bin/python
This is fixed in master, closing for now
@techalchemy Is there a PR or commit we could reference?
I met a similar problem but then I found this FAQ which solved my problem.
https://pipenv.readthedocs.io/en/latest/diagnose/#pipenv-does-not-respect-pyenvs-global-and-local-python-versions
Most helpful comment
I am also experiencing the same issue with:
Specifying the version explicitly with pipenv solved my issue