pipenv: pipenv using wrong python with pyenv

pipenv is using python 3.5.3 instead of 3.6.2 for some reason

$ pipenv --version
pipenv, version 8.0.7
$ python --version
Python 3.6.2
$ which python
/Users/johria/.pyenv/shims/python
$ pipenv install --dev
Creating a virtualenv for this project…
⠋Using base prefix '/Users/johria/.pyenv/versions/3.5.3'
New python executable in /Users/johria/.local/share/virtualenvs/context-generator-d3x1ENAX/bin/python3.5
Also creating executable in /Users/johria/.local/share/virtualenvs/context-generator-d3x1ENAX/bin/python
Installing setuptools, pip, wheel...done.

Virtualenv location: /Users/johria/.local/share/virtualenvs/context-generator-d3x1ENAX
Installing dependencies from Pipfile.lock…
  🐍   ▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉ 25/25 — 00:00:44
To activate this project's virtualenv, run the following:
 $ pipenv shell
$ pyenv versions
  system
  2.7.13
  3.5.3
* 3.6.2 (set by /Users/johria/Development/heliograf/apps/context-generator/.python-version)

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Reactions: 2
  • Comments: 42 (26 by maintainers)

Most upvoted comments

$ pipenv --rm
$ pipenv install
$ Creating a virtualenv for this project…
Using /Users/johria/.pyenv/versions/3.6.2/bin/python3.6m to create virtualenv…

fixed! thank you all! 🎉

you’ll have to do a pipenv --rm to start over.

pipenv doesn’t look at .python-version or runtime.txt files to determine which python version to look for, as @nateprewitt mentioned add python_requires to your Pipfile, otherwise be explicit: pipenv --python 3.6.2 install --dev

;TLDR for those who ran into this problem:

pipenv --rm
pipenv install --python V

Replace V with the value of the python_version parameter from your Pipfile

If you are just starting a new project and do not have a Pipfile yet, replace V with the Python version that you set up for this project with asdf, pyenv, or whatever tool you are using to manage Python versions.

use python_full_version = "3.6.2".

I just upgraded my Python from 3.7.1 to 3.7.2 and I started having problem. My simple solution was to run “pipenv rm” and then “pipenv install -r requirements.txt” and the Python in the virtualenv has been updated to 3.7.2, which is what I wanted.

@SergiyKolesnikov I did see that, so I understand what is happening. Sorry, I only meant to offer a different workaround for others experiencing this issue. I had tried pipenv --python=$PYENV_ROOT/shims/python from this comment, but that didn’t work for me because PYENV_ROOT is not in my env. pipenv --python=$(which python3) is what I ended up using, instead.

@aleksijohansson The .python-version proposal was already rejected a while ago because we want to avoid supporting non-standard stuff if possible. Use pipenv --python=$PYENV_ROOT/shims/python if you want to hook into the .python-version configuration.

Someone integrate PythonFinder please!

@uranusjr I understand and that makes sense. Relying on python --version could be good though. Thanks for the suggested workaround!