pipenv always create new virtualenv if PIPENV_SITE_PACKAGES=1 is set
See original GitHub issueIssue description
When the environment variable PIPENV_SITE_PACKAGES is set, pipenv always recreate new virtualenv on each invoke of pipenv even if it is not a pipenv install command.
Expected result
pipenv runorpipenv shellshould use existing virtualenv instead of creating a new one.PIPENV_SITE_PACKAGESshould only affectpipenv installcommand.
Actual result
root@9e08ac3143d2:/tmp# pipenv && pipenv && pipenv
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: /tmp/Pipfile
Using /usr/bin/python3.8 (3.8.5) to create virtualenv...
Making site-packages available...
⠼ Creating virtual environment...created virtual environment CPython3.8.5.final.0-64 in 254ms
creator CPython3Posix(dest=/root/.local/share/virtualenvs/tmp-XVr6zr33, clear=False, global=True)
seeder FromAppData(download=False, pip=bundle, setuptools=bundle, wheel=bundle, via=copy, app_data_dir=/root/.local/share/virtualenv)
added seed packages: pip==20.2.4, setuptools==50.3.2, wheel==0.35.1
activators BashActivator,CShellActivator,FishActivator,PowerShellActivator,PythonActivator,XonshActivator
✔ Successfully created virtual environment!
Virtualenv location: /root/.local/share/virtualenvs/tmp-XVr6zr33
Creating a Pipfile for this project...
Virtualenv already exists!
Removing existing virtualenv...
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: /tmp/Pipfile
Using /usr/bin/python3.8 (3.8.5) to create virtualenv...
Making site-packages available...
⠼ Creating virtual environment...created virtual environment CPython3.8.5.final.0-64 in 235ms
creator CPython3Posix(dest=/root/.local/share/virtualenvs/tmp-XVr6zr33, clear=False, global=True)
seeder FromAppData(download=False, pip=bundle, setuptools=bundle, wheel=bundle, via=copy, app_data_dir=/root/.local/share/virtualenv)
added seed packages: pip==20.2.4, setuptools==50.3.2, wheel==0.35.1
activators BashActivator,CShellActivator,FishActivator,PowerShellActivator,PythonActivator,XonshActivator
✔ Successfully created virtual environment!
Virtualenv location: /root/.local/share/virtualenvs/tmp-XVr6zr33
Virtualenv already exists!
Removing existing virtualenv...
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: /tmp/Pipfile
Using /usr/bin/python3.8 (3.8.5) to create virtualenv...
Making site-packages available...
⠼ Creating virtual environment...created virtual environment CPython3.8.5.final.0-64 in 239ms
creator CPython3Posix(dest=/root/.local/share/virtualenvs/tmp-XVr6zr33, clear=False, global=True)
seeder FromAppData(download=False, pip=bundle, setuptools=bundle, wheel=bundle, via=copy, app_data_dir=/root/.local/share/virtualenv)
added seed packages: pip==20.2.4, setuptools==50.3.2, wheel==0.35.1
activators BashActivator,CShellActivator,FishActivator,PowerShellActivator,PythonActivator,XonshActivator
✔ Successfully created virtual environment!
Virtualenv location: /root/.local/share/virtualenvs/tmp-XVr6zr33
root@9e08ac3143d2:/tmp#
Steps to replicate
docker run -it ubuntu bash- Inside docker:
apt update && apt install -y python3 python3-pip && pip3 install pipenv && export PIPENV_SITE_PACKAGES=1 - run any pipenv command, in the example I use
pipenv && pipenv && pipenv
Pipenv version: '2020.11.15'
Pipenv location: '/usr/local/lib/python3.8/dist-packages/pipenv'
Python location: '/usr/bin/python3'
Python installations found:
3.8.5:/usr/bin/python3.83.8.5:/usr/bin/python33.8.5:/bin/python3.83.8.5:/bin/python3
PEP 508 Information:
{'implementation_name': 'cpython',
'implementation_version': '3.8.5',
'os_name': 'posix',
'platform_machine': 'x86_64',
'platform_python_implementation': 'CPython',
'platform_release': '5.4.39-linuxkit',
'platform_system': 'Linux',
'platform_version': '#1 SMP Fri May 8 23:03:06 UTC 2020',
'python_full_version': '3.8.5',
'python_version': '3.8',
'sys_platform': 'linux'}
System environment variables:
HOSTNAMEPWDHOMELS_COLORSTERMPIPENV_SITE_PACKAGESSHLVLPATHOLDPWD_LC_CTYPEPIP_DISABLE_PIP_VERSION_CHECKPYTHONDONTWRITEBYTECODEPIP_SHIMS_BASE_MODULEPIP_PYTHON_PATHPYTHONFINDER_IGNORE_UNSUPPORTED
Pipenv–specific environment variables:
PIPENV_SITE_PACKAGES:1
Debug–specific environment variables:
PATH:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/binPWD:/tmp
Contents of Pipfile (‘/tmp/Pipfile’):
[[source]]
url = "https://pypi.org/simple"
verify_ssl = true
name = "pypi"
[packages]
[dev-packages]
[requires]
python_version = "3.8"
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:7 (4 by maintainers)
Top Results From Across the Web
Advanced Usage of Pipenv - Read the Docs
Pipenv will expand environment variables (if defined) in your Pipfile. ... And generate a set of requirements out of it with only the...
Read more >How to manage your python virtualenvs with Pipenv
Let's see how to install, setup and create a virtualenv for a project all via pipenv. We would use terminal commands and see...
Read more >Force pipenv to create a new virtualenv - Stack Overflow
I think it's because I've installed pipenv in a virtualenv. It says it's reusing that virtualenv instead of creating a new one. My...
Read more >pipenv Documentation - manpages.ubuntu!
It automatically creates and manages a virtualenv for your projects, ... pip install pipenv ✨ ✨ If you have excellent taste, there's...
Read more >pipenv Documentation - Read the Docs
Will create a virtual env and install dependencies (if it does not exist ... If set, Pipenv will always assign a virtual environment...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

Currently passing
--site-packages, the equivalent of settingPIPENV_SITE_PACKAGES, will be regarded as the user wants to change the virtualenv properties. So it is a one-pass flag rather than a persistent setting, but it should be easy to fix: https://github.com/pypa/pipenv/blob/47d8b96e10e462169cb9d3e719318565514408ad/pipenv%2Fcore.py#L519-L546Any interest in submitting a PR?
I have tried to run the code on my computer. On running the command “pipenv --three” it shows that virtual environment already exists and then it removes the existing virtual environment and create new one. My doubt is that we have to remove this functionality and add if any virtual environment exists it should use that?