Hi,
See my following testing on using the env var PIPENV_PYTHON:
Run the following commands from my project folder:
$ pipenv --version
pipenv, version 2018.11.26
$ env | grep PIPENV_PYTHON
PIPENV_PYTHON=/home/werner/.pyenv/shims/python
$ /home/werner/.pyenv/shims/python --version
Python 3.4.9
$ pipenv --three
Creating a virtualenv for this project…
Pipfile: /home/werner/aaa/Pipfile
Using /home/werner/.pyenv/versions/3.7.5/bin/python3 (3.7.5) to create virtualenv…
â § Creating virtual environment...Already using interpreter /home/werner/.pyenv/versions/3.7.5/bin/python3
Using base prefix '/home/werner/.pyenv/versions/3.7.5'
New python executable in /home/werner/aaa/.venv/bin/python3
Also creating executable in /home/werner/aaa/.venv/bin/python
Installing setuptools, pip, wheel...
done.
Running virtualenv with interpreter /home/werner/.pyenv/versions/3.7.5/bin/python3
✔ Successfully created virtual environment!
Virtualenv location: /home/werner/aaa/.venv
Creating a Pipfile for this project…
As you can see, I set the PIPENV_PYTHON the env var, and it's pointing to python 3.4.9, why still the pipenv will use another python version, for my case, it's 3.7.5?
Regards
I think you're looking for export PIPENV_DEFAULT_PYTHON_VERSION=3.7
No, I don't want to use method, though I don't try it either. But IMO, this method is not portable, I want to let the pipenv use the python version set by pyenv locally/globally.
Regards
Any update? I have the same issue
I'll take a wild guess that --three
points to the system
Python3
version and not the one pyenv
sets up.
In my case, I have set export PIPENV_PYTHON=$HOME/.pyenv/shims/python
and by using pipenv install -d
it always uses the version pyenv
sets.
PIPENV_PYTHON
is not meant to point at a full python path, it is only ever meant to point at a numeric python version (e.g. 3.7
. Whatever you set in PIPENV_PYTHON
will be appended to the name of the virtualenv created by pipenv, e.g. /path/to/your/.virtualenvs/yourfolder-<somehash>-$PIPENV_PYTHON
-- this is meant for use in environments where you intend to have multiple versions of the same virtual environment for a single project, so you might want, for instance:
for pyversion in 2.7 3.6 3.7 3.8;
do PIPENV_PYTHON=$pyversion pipenv install --dev && \
PIPENV_PYTHON=$pyversion pipenv run pytest;
done
If you would like to specify a python version, you will have to pass that in directly via --python
(e.g. pipenv install --python=/path/to/python
). As a side note, pyenv's shim python path is just a shell script that wraps some pyenv internals, so there is no guarantee that will actually resolve to python when pipenv encounters it. Pipenv bypasses pyenv shims by default and works more successfully if you specify nothing (as it will determine that you are using pyenv and resolve the shim for you -- at least in the next release it will).
I would strongly recommend using only the version number to tell pipenv which python version you are looking for, e.g. 3.8
or 2.7
or whatever version you like, as this will ensure that you don't wind up with mangled environment paths that become orphaned if you misremember them or fail to set the environment up again later.
Hope this helps to clear up how the environment variable works -- if you are still struggling, make sure to use the latest prerelease of pipenv (pip install --upgrade --pre pipenv
) as it will provide more of the functionality you are looking for.
Thanks!
Most helpful comment
No, I don't want to use method, though I don't try it either. But IMO, this method is not portable, I want to let the pipenv use the python version set by pyenv locally/globally.
Regards