pipenv icon indicating copy to clipboard operation
pipenv copied to clipboard

Pipenv uses arbitrary python installation on windows

Open ITR13 opened this issue 3 years ago • 6 comments

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

  1. Create a directory named "test" on the C drive
  2. Run python -m pip uninstall pipenv then python -m pip install pipenv
  3. 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.exe
  • 2.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:

  • ALLUSERSPROFILE
  • ANDROID_HOME
  • APPDATA
  • BEEFPATH
  • BESIEGE_GAME_ASSEMBLIES
  • BESIEGE_UNITY_ASSEMBLIES
  • CGO_CFLAGS_ALLOW
  • CGO_CXXFLAGS_ALLOW
  • CGO_LDFLAGS_ALLOW
  • CHOCOLATEYINSTALL
  • CHOCOLATEYLASTPATHUPDATE
  • CMAKE_PREFIX_PATH
  • CMDER_ROOT
  • COMMONPROGRAMFILES
  • COMMONPROGRAMFILES(X86)
  • COMMONPROGRAMW6432
  • COMPUTERNAME
  • COMSPEC
  • CONEMUDIR
  • CPATH
  • CUDA_PATH
  • CUDA_PATH_V10_1
  • CUDA_PATH_V10_2
  • DRIVERDATA
  • FORKGITINSTANCE
  • GEM_HOME
  • GEM_PATH
  • GIT_INSTALL_ROOT
  • GIT_SSH
  • GOPATH
  • GOROOT
  • GTK_BASEPATH
  • HOMEDRIVE
  • HOMEPATH
  • JAVA_HOME
  • LOCALAPPDATA
  • LOGONSERVER
  • NGINX_HOME
  • NODE_PATH
  • NUMBER_OF_PROCESSORS
  • NVCUDASAMPLES10_1_ROOT
  • NVCUDASAMPLES_ROOT
  • NVM_HOME
  • NVM_SYMLINK
  • NVTOOLSEXT_PATH
  • ONEDRIVE
  • OS
  • PATH
  • PATHEXT
  • PHP_INI_SCAN_DIR
  • PKG_CONFIG
  • PKG_CONFIG_PATH
  • PROCESSOR_ARCHITECTURE
  • PROCESSOR_IDENTIFIER
  • PROCESSOR_LEVEL
  • PROCESSOR_REVISION
  • PROGRAMDATA
  • PROGRAMFILES
  • PROGRAMFILES(X86)
  • PROGRAMW6432
  • PROGUARD_HOME
  • PROMPT
  • PSMODULEPATH
  • PUBLIC
  • PYENV
  • PYENV_HOME
  • PYENV_ROOT
  • SCROLLVIEW_PATH
  • SESSIONNAME
  • STEAMROOT
  • SYSTEMDRIVE
  • SYSTEMROOT
  • TEMP
  • TESSDATA_PREFIX
  • TMP
  • U2NETHS_PATH
  • U2NETP_PATH
  • U2NET_PATH
  • USERDOMAIN
  • USERDOMAIN_ROAMINGPROFILE
  • USERNAME
  • USERPROFILE
  • VS140COMNTOOLS
  • WINDIR
  • PIP_SHIMS_BASE_MODULE
  • PIP_DISABLE_PIP_VERSION_CHECK
  • PIP_PYTHON_PATH
  • PYTHONDONTWRITEBYTECODE
  • PYTHONFINDER_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;

ITR13 avatar Jul 30 '22 23:07 ITR13

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

ITR13 avatar Jul 31 '22 04:07 ITR13

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?

bakhtiary avatar Aug 08 '22 13:08 bakhtiary

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.

ITR13 avatar Aug 09 '22 03:08 ITR13

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.

matteius avatar Aug 15 '22 12:08 matteius

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?

matteius avatar Aug 31 '22 12:08 matteius

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.

ITR13 avatar Sep 03 '22 08:09 ITR13

Please recheck this on pipenv==2023.5.19

matteius avatar May 20 '23 11:05 matteius