Pipenv uses arbitrary python installation on windows
Similar to #4952, but happens on a clean pyenv install and while creating an environment. I'm using Python 3.10.4 installed with scoop. This happens both in cmd and in a bash shell.
Issue description
I installed pipenv using the python installation in my path, but when I run pipenv --support it only manages to find my python 2.7 installation, and an python 3.6.5 installation that came with an old julia installation, neither of which are in path. Attempting to create a new pipenv automatically uses the 3.6.5 installation.
Expected result
Pipenv uses the first python found in path
Actual result
Pipenv uses an arbitrary python installation I have no idea how it finds.
Steps to replicate
- Create a directory named "test" on the C drive
- Run
python -m pip uninstall pipenvthenpython -m pip install pipenv - Run
pipenv --support
C:\test>where python
C:\Users\ITR\scoop\apps\python\current\python.exe
$ pipenv --support
Pipenv version: '2022.7.24'
Pipenv location: 'C:\\Users\\ITR\\scoop\\apps\\python\\current\\lib\\site-packages\\pipenv'
Python location: 'C:\\Users\\ITR\\scoop\\apps\\python\\current\\python.exe'
Python installations found:
3.6.5:C:\Users\ITR\.julia\conda\3\python.exe2.7.18:C:\Users\ITR\scoop\apps\python27\current\python.exe
PEP 508 Information:
{'implementation_name': 'cpython',
'implementation_version': '3.10.4',
'os_name': 'nt',
'platform_machine': 'AMD64',
'platform_python_implementation': 'CPython',
'platform_release': '10',
'platform_system': 'Windows',
'platform_version': '10.0.19044',
'python_full_version': '3.10.4',
'python_version': '3.10',
'sys_platform': 'win32'}
System environment variables:
ALLUSERSPROFILEANDROID_HOMEAPPDATABEEFPATHBESIEGE_GAME_ASSEMBLIESBESIEGE_UNITY_ASSEMBLIESCGO_CFLAGS_ALLOWCGO_CXXFLAGS_ALLOWCGO_LDFLAGS_ALLOWCHOCOLATEYINSTALLCHOCOLATEYLASTPATHUPDATECMAKE_PREFIX_PATHCMDER_ROOTCOMMONPROGRAMFILESCOMMONPROGRAMFILES(X86)COMMONPROGRAMW6432COMPUTERNAMECOMSPECCONEMUDIRCPATHCUDA_PATHCUDA_PATH_V10_1CUDA_PATH_V10_2DRIVERDATAFORKGITINSTANCEGEM_HOMEGEM_PATHGIT_INSTALL_ROOTGIT_SSHGOPATHGOROOTGTK_BASEPATHHOMEDRIVEHOMEPATHJAVA_HOMELOCALAPPDATALOGONSERVERNGINX_HOMENODE_PATHNUMBER_OF_PROCESSORSNVCUDASAMPLES10_1_ROOTNVCUDASAMPLES_ROOTNVM_HOMENVM_SYMLINKNVTOOLSEXT_PATHONEDRIVEOSPATHPATHEXTPHP_INI_SCAN_DIRPKG_CONFIGPKG_CONFIG_PATHPROCESSOR_ARCHITECTUREPROCESSOR_IDENTIFIERPROCESSOR_LEVELPROCESSOR_REVISIONPROGRAMDATAPROGRAMFILESPROGRAMFILES(X86)PROGRAMW6432PROGUARD_HOMEPROMPTPSMODULEPATHPUBLICPYENVPYENV_HOMEPYENV_ROOTSCROLLVIEW_PATHSESSIONNAMESTEAMROOTSYSTEMDRIVESYSTEMROOTTEMPTESSDATA_PREFIXTMPU2NETHS_PATHU2NETP_PATHU2NET_PATHUSERDOMAINUSERDOMAIN_ROAMINGPROFILEUSERNAMEUSERPROFILEVS140COMNTOOLSWINDIRPIP_SHIMS_BASE_MODULEPIP_DISABLE_PIP_VERSION_CHECKPIP_PYTHON_PATHPYTHONDONTWRITEBYTECODEPYTHONFINDER_IGNORE_UNSUPPORTED
PipenvΓÇôspecific environment variables:
DebugΓÇôspecific environment variables:
PATH:C:\Program Files\Common Files\Oracle\Java\javapath;D:\Program Files\Eclipse Adoptium\jdk-8.0.322.6-hotspot\bin;C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.2\bin;C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.2\libnvvp;C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.1\bin;C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.1\libnvvp;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;D:\Go\GoPath\bin;D:\misc;D:\OpenFaceSwap;C:\WINDOWS\System32\OpenSSH\;C:\Program Files (x86)\GtkSharp\2.12\bin;D:\Program Files\Microsoft Network Monitor 3\;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files\NVIDIA Corporation\NVIDIA NvDLISR;D:\Go\bin;C:\ProgramData\chocolatey\bin;C:\Program Files\NVIDIA Corporation\Nsight Compute 2019.5.0\;C:\cuDNN\bin;D:\Program Files\javafx-sdk-14.0.1\bin;D:\Program Files\javafx-sdk-14.0.1\lib;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\WINDOWS\System32\OpenSSH\;D:\misc\swigwin-3.0.12;D:\Program Files\Calibre2\;C:\Program Files\dotnet\;C:\Users\ITR\scoop\apps\python\current\Scripts;C:\Users\ITR\scoop\apps\python\current;C:\Users\ITR\scoop\apps\nodejs\current\bin;C:\Users\ITR\scoop\apps\nodejs\current;C:\Users\ITR\.nimble\bin;C:\Users\ITR\scoop\apps\gpg\current\bin;C:\Users\ITR\scoop\apps\adopt8-hotspot\current\bin;C:\Users\ITR\scoop\apps\perl\current\perl\site\bin;C:\Users\ITR\scoop\apps\perl\current\perl\bin;C:\Users\ITR\scoop\apps\perl\current\c\bin;C:\Users\ITR\scoop\apps\flutter\current\bin\cache\dart-sdk\bin;C:\Users\ITR\scoop\apps\ruby\current\bin;C:\Users\ITR\scoop\apps\ruby\current\gems\bin;C:\Users\ITR\scoop\apps\oraclejdk\current\bin;C:\Users\ITR\scoop\apps\gcc\current\bin;C:\Users\ITR\scoop\apps\yarn\current\Yarn\bin;C:\Users\ITR\scoop\apps\yarn\current\global\node_modules\.bin;C:\Users\ITR\scoop\apps\python27\current\scripts;C:\Users\ITR\scoop\apps\flutter\current\bin\cache\dart-sdk;C:\Python64\Scripts\;C:\Python64\;C:\Users\ITR\scoop\apps\nvm\current\nodejs\nodejs;C:\Users\ITR\AppData\Local\Programs\Python\Python36-32\Scripts\;C:\Users\ITR\AppData\Local\Programs\Python\Python36-32\;C:\Users\ITR\AppData\Local\Programs\Python\Launcher\;C:\Users\ITR\scoop\apps\android-sdk\current\tools\bin;C:\Users\ITR\scoop\apps\nmap\current\bin;C:\Users\ITR\scoop\apps\openjdk\current\bin;C:\Users\ITR\scoop\shims;C:\Users\ITR\scoop\apps\sdl2-msvc-x64\current\lib;D:\Program Files\RingLang\ring\bin;C:\Users\ITR\go\bin;D:\Program Files\Beef Lang\bin;C:\Users\ITR\AppData\Local\Programs\Microsoft VS Code\bin;D:\Program Files (x86)\Nmap;C:\Users\ITR\.dotnet\tools;C:\Users\ITR\.dotnet\tools;C:\Users\ITR\.dotnet\tools;D:\User\AppData\Local\Programs\Hyper\resources\bin;C:\Users\ITR\.dotnet\tools;C:\Users\ITR\.pyenv\pyenv-win\\bin;C:\Users\ITR\.pyenv\pyenv-win\\shims;C:\Users\ITR\AppData\Roaming\Python\Python310\Scripts;
Update: Managed to have it find the correct installation by using --python 3.10.
Still unsure why this isn't the default and why it does not show up in --support
This is a hard one! I need more info to address it. could you answer the following questions? maybe I can help.
which python is used by default? To find out try python --version
which pipenv is picked up by default? To find out try where pipenv
does python -m pipenv --support give the same output as pipenv --support?
Ran a diff on the output of pipenv --support and python -m pipenv --support, both are the same.
python --version is 3.10.4
where pipenv is C:\Users\ITR\scoop\apps\python\current\Scripts\pipenv.exe
Despite the support output not having changed, pipenv now correctly creates a 3.10 virtualenv even when I don't use --python 3.10 (I haven't tried reinstalling pipenv again to see if it persists).
I've thought some more about it, and remembered that scoop uses a symlink for the current python version. C:\Users\ITR\scoop\apps\python\ has 3.6.5, 3.7.2, 3.7.3, 3.8.0, 3.8.3, 3.8.5, 3.10.4, and the directory junction "current" that points to 3.10.4 and is in path.
These folders also don't appear in --support (only "current" is in path), and also aren't found when using --python 3.8.
For 3.6 it finds C:/Users/ITR/AppData/Local/Programs/Python36-32/python.exe which also wasn't in the list, I think this comes from the windows store? A bit unsure. For 3.7 it finds C:/Python64/python.exe which is a 64bit version of python 3.7 I needed for some machine learning projects a few years back.
Neither of these folders appear in the --support list of python installations found.
I must admit, writing all this reminds me of a certain xkcd comic. I am tempted to start deleting some of these I no longer use to see if the --support text changes.
That's a funny xkcd coming @ITR13 :-D
There is a new version of pipenv=2022.8.15 -- it doesn't specifically change anything with regards to creating the virtualenv though, in fact as far as I can tell nothing recently has addressed that specific code. I suspect that in the code path core.ensure_python that you are not relying on pyenv to install the version of Python, so its falling back to logic to look for the system python later on in the method.
The newest version of pipenv is searching for python3 before python, this also helps in some cases. @ITR13 I noticed in your last reply that you said the issue kind of went away for you? Is there something actionable remaining that we should do related to this ticket?
There's still the issue of pipenv --support only listing 2 python installations, but for installation it now works, yes. It's possible it stored which python executable I used after I forced it to use python 3.8 (I haven't uninstalled and reinstalled since it's working). Same behaviour on latest pipenv version.
I can close the issue since --support not listing the correct python installations is just a minor issue, unless you want me to keep it open for it.
Please recheck this on pipenv==2023.5.19