pipenv icon indicating copy to clipboard operation
pipenv copied to clipboard

`pipenv install` uses one Python version for the venv and another for the Pipfile

Open tucked opened this issue 2 years ago • 2 comments

root@0b68b226bc0c:/# python3.8 -m pipenv --version
pipenv, version 2023.11.15
root@0b68b226bc0c:/# python3.8 -m pipenv install six && python3.8 -m pipenv check
Warning: the environment variable LANG is not set!
We recommend setting this in ~/.profile (or equivalent) for proper expected behavior.
Creating a virtualenv for this project...
Pipfile: /Pipfile
Using default python from /usr/bin/python3.8 (3.8.10) to create virtualenv...
⠸ Creating virtual environment...created virtual environment CPython3.8.10.final.0-64 in 873ms
  creator CPython3Posix(dest=/root/.local/share/virtualenvs/-x-v5uFv0, clear=False, no_vcs_ignore=False, global=False)
  seeder FromAppData(download=False, pip=bundle, setuptools=bundle, wheel=bundle, via=copy, app_data_dir=/root/.local/share/virtualenv)
    added seed packages: pip==23.3.1, setuptools==69.0.2, wheel==0.42.0
  activators BashActivator,CShellActivator,FishActivator,NushellActivator,PowerShellActivator,PythonActivator

✔ Successfully created virtual environment!
Virtualenv location: /root/.local/share/virtualenvs/-x-v5uFv0
Creating a Pipfile for this project...
Installing six...
Resolving six...
Added six to Pipfile's [packages] ...
✔ Installation Succeeded
Pipfile.lock not found, creating...
Locking [packages] dependencies...
Building requirements...
Resolving dependencies...
✔ Success!
Locking [dev-packages] dependencies...
Updated Pipfile.lock (cee4dc4477afda965b20e2557953f68b5d58c07371503303e5b0d8eb27060c30)!
Installing dependencies from Pipfile.lock (060c30)...
To activate this project's virtualenv, run pipenv shell.
Alternatively, run a command inside the virtualenv with pipenv run.
Checking PEP 508 requirements...
Specifier python_version does not match 2.7 (3.8).
Failed!

Namely:

Using default python from /usr/bin/python3.8 (3.8.10) to create virtualenv...

root@0b68b226bc0c:/# tail -n2 Pipfile
[requires]
python_version = "2.7"

Full repro:

docker run -it ubuntu:focal
apt update
apt install python python3-pip
python3 -m pip install --user pipenv
python3 -m pipenv install six
python3 -m pipenv check

tucked avatar Dec 15 '23 20:12 tucked

Well if the virtualenv was already established for the project and the Pipfile were adjusted to have a newer version specified, there is no mechanics to recreate that old virtualenv. Also the minimum version modern pipenv supports is Python 3.8

matteius avatar Jan 27 '24 06:01 matteius

Well if the virtualenv was already established for the project

It wasn't tho

Creating a virtualenv for this project...

Also the minimum version modern pipenv supports is Python 3.8

This makes the insertion of python_version = "2.7" even stranger. I would have expected the Pipfile to have the version that was used to create the virtualenv.

tucked avatar Jan 30 '24 21:01 tucked