Reputation: 12405
How does pipenv decide my python version? My default python3 version is different from the version pipenv decided. A simple example to illustrate my problem. Pipefile said 3.8 while my python3 is 3.9.
pyenv_test β€ cat requirements.txt
pexpect==4.8.0
termcolor==1.1.0
pyenv_test β€ pipenv install
requirements.txt found, instead of Pipfile! Converting...
β Success!
Warning: Your Pipfile now contains pinned versions, if your requirements.txt did.
We recommend updating your Pipfile to specify the "*" version, instead.
Pipfile.lock not found, creating...
Locking [dev-packages] dependencies...
Locking [packages] dependencies...
Building requirements...
Resolving dependencies...
β Success!
Updated Pipfile.lock (a46966)!
Installing dependencies from Pipfile.lock (a46966)...
π ββββββββββββββββββββββββββββββββ 0/0 β 00:00:00
To activate this project's virtualenv, run pipenv shell.
Alternatively, run a command inside the virtualenv with pipenv run.
pyenv_test β€ cat Pipfile
[[source]]
url = "https://pypi.org/simple"
verify_ssl = true
name = "pypi"
[packages]
pexpect = "==4.8.0"
termcolor = "==1.1.0"
[dev-packages]
[requires]
python_version = "3.8"
pyenv_test β€ which python3
/Library/Frameworks/Python.framework/Versions/3.9/bin/python3
Another problem I found is the requirement.text it generated was different from the one created Pipefile in the first place.
pyenv_test β€ pipenv lock -r
#
# These requirements were autogenerated by pipenv
# To regenerate from the project's Pipfile, run:
#
# pipenv lock --requirements
#
-i https://pypi.org/simple
pexpect==4.8.0
ptyprocess==0.6.0
termcolor==1.1.0
Comparing with my requirements.txt that generated the Pipefile in the first place it added ptyprocess. As the comment pointed out ptyprocess is used by pexpect. But why did Pipefile add that as another requirement.
Upvotes: 2
Views: 14338
Reputation: 12405
I opened an issue against pipenv https://github.com/pypa/pipenv/issues/4546, after discussing with one of maintainers, I now understood why my problem happened.
For my first issue, when run pipenv install
pipenv reused the existing one which was python 3.8, i.e. venv is not recreated. I feel it looks like a problem, why reuse a venv on a new project?
For my second issue, it does help me understand what does "produce deterministic builds" mean. ptyprocess is used by pexpect. I check pexpect's setup.py https://github.com/pexpect/pexpect/blob/master/setup.py
install_requires=['ptyprocess>=0.5'],
So by specifying ptyprocess==0.6.0 & pexpect==4.8.0
in requirement.txt does produce deterministic build.
Upvotes: 0
Reputation: 1479
Looking at the pipenv
docs on specifying a python version it states:
If you donβt specify a Python version on the commandβline, either the [requires]
python_full_version
orpython_version
will be selected automatically, falling back to whatever your systemβs default python installation is, at time of execution.
My guess is you initialized your pipenv
project before you upgraded to python 3.9.
If you do want to update your Pipfile
to specify your specific version of python you can simply:
pipenv --python 3.9
You can of course also manually update the python_version
in your Pipfile
.
Upvotes: 4