pipenv icon indicating copy to clipboard operation
pipenv copied to clipboard

Pythonfinder should support the windows `py` command

Open taronaldinho opened this issue 2 years ago • 4 comments

Since upgrading pipenv to v2023.5.19, it does not successfully recognize the version of Python installed on my PC. It fails as follows.

PS > py -m pipenv --python 3.9
Warning: Python 3.9 was not found on your system...
Neither 'pyenv' nor 'asdf' could be found to install Python.
You can specify specific versions of Python with:
$ pipenv --python path\to\python

The path to each version of Python installed on the PC can be found from the py command. (I have not added the Python PATH according to the default installer settings.)

PS > py --list-paths
 -V:3.11 *        [USERPROFILE]\AppData\Local\Programs\Python\Python311\python.exe
 -V:3.10          [USERPROFILE]\AppData\Local\Programs\Python\Python310\python.exe
 -V:3.9           [USERPROFILE]\AppData\Local\Programs\Python\Python39\python.exe
 -V:3.8           [USERPROFILE]\AppData\Local\Programs\Python\Python38\python.exe
 -V:3.7           [USERPROFILE]\AppData\Local\Programs\Python\Python37\python.exe

Therefore, as indicated in the error message, the virtual environment can be successfully created by specifying the Python path to be used.

> py -m pipenv --python [USERPROFILE]\AppData\Local\Programs\Python\Python39\python.exe
-> It's OK.

However, by simply downgrading pipenv to v2023.4.29, the above command succeeds as before.

PS > py -m pip install -U pipenv==2023.4.29

...

Successfully installed pipenv-2023.4.29

PS > py -m pipenv --python 3.9
Creating a virtualenv for this project...

...

Successfully created virtual environment!
Virtualenv location: [VENV PATH]
Creating a Pipfile for this project...

The same problem occurred on three PCs (Windows 10 and 11). Are there any steps that should be changed to enable the creation of virtual environments with py -m pipenv --python commands without specifying the full path of Python?


$ pipenv --support

Pipenv version: '2023.7.3'

Pipenv location: '[USERPROFILE]\\AppData\\Local\\Programs\\Python\\Python311\\Lib\\site-packages\\pipenv'

Python location: '[USERPROFILE]\\AppData\\Local\\Programs\\Python\\Python311\\python.exe'

OS Name: 'nt'

User pip version: '23.1.2'

user Python installations found:

PEP 508 Information:

{'implementation_name': 'cpython',
 'implementation_version': '3.11.3',
 'os_name': 'nt',
 'platform_machine': 'AMD64',
 'platform_python_implementation': 'CPython',
 'platform_release': '10',
 'platform_system': 'Windows',
 'platform_version': '10.0.19045',
 'python_full_version': '3.11.3',
 'python_version': '3.11',
 'sys_platform': 'win32'}

System environment variables:

  • ALLUSERSPROFILE
  • APPDATA
  • COMMONPROGRAMFILES
  • COMMONPROGRAMFILES(X86)
  • COMMONPROGRAMW6432
  • COMPUTERNAME
  • COMSPEC
  • CUDA_PATH
  • CUDA_PATH_V11_8
  • DRIVERDATA
  • HOMEDRIVE
  • HOMEPATH
  • LIB
  • LOCALAPPDATA
  • LOGONSERVER
  • MEFTLOGROOT
  • MMM_COM_SLACK_API_TOKEN
  • NUMBER_OF_PROCESSORS
  • NVTOOLSEXT_PATH
  • ONEDRIVE
  • OS
  • PATH
  • PATHEXT
  • PIPENV_VENV_IN_PROJECT
  • PROCESSOR_ARCHITECTURE
  • PROCESSOR_IDENTIFIER
  • PROCESSOR_LEVEL
  • PROCESSOR_REVISION
  • PROGRAMDATA
  • PROGRAMFILES
  • PROGRAMFILES(X86)
  • PROGRAMW6432
  • PSMODULEPATH
  • PUBLIC
  • SYSTEMDRIVE
  • SYSTEMROOT
  • TEMP
  • TMP
  • USERDNSDOMAIN
  • USERDOMAIN
  • USERDOMAIN_ROAMINGPROFILE
  • USERNAME
  • USERPROFILE
  • WINDIR
  • WSLENV
  • WT_PROFILE_ID
  • WT_SESSION
  • ZES_ENABLE_SYSMAN
  • PYTHONDONTWRITEBYTECODE
  • PIP_DISABLE_PIP_VERSION_CHECK
  • PYTHONFINDER_IGNORE_UNSUPPORTED

Pipenv–specific environment variables:

  • PIPENV_VENV_IN_PROJECT: true

Debug–specific environment variables:

  • PATH: C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.8\bin;C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.8\libnvvp;C:\oracle\11gr2\prones\bin;C:\Program Files (x86)\NetCOBOL\;C:\Program Files (x86)\Common Files\Fujitsu\MeFt\;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Program Files\dotnet\;C:\Program Files\Microsoft SQL Server\120\Tools\Binn\;C:\Program Files\nodejs\;C:\Program Files\Git\cmd;C:\Program Files\NVIDIA Corporation\Nsight Compute 2022.3.0\;C:\Program Files (x86)\Windows Kits\8.1\Windows Performance Toolkit\;[USERPROFILE]\.cargo\bin;[USERPROFILE]\AppData\Local\Microsoft\WindowsApps;[USERPROFILE]\AppData\Local\Programs\Microsoft VS Code\bin;[USERPROFILE]\.dotnet\tools;[USERPROFILE]\AppData\Roaming\npm;[USERPROFILE]\.dotnet\tools

taronaldinho avatar Jul 04 '23 06:07 taronaldinho

This is the first I've learned of the py command, and unfortunately it was not in our documentation that this was ever supported. I welcome to pythonfinder PRs that could support this, but what probably happened is in the refactor to pythonfinder -> pydantic, I encountered that we were using a completely different library to find Windows pythons which was creating problems with trying to have consistent code paths that we maintain and can fix windows bugs in. So now all operating systems use the same pythonfinder code paths that we maintain so it should be possible to support this again in the future.

matteius avatar Jul 05 '23 05:07 matteius

@matteius Thank you for commenting on my problem. It would be great if the py command was supported again.

taronaldinho avatar Jul 06 '23 04:07 taronaldinho

I've labeled it as something that will be considered for PR improvements, but myself and the other maintainer have limited bandwidth at present to make all of these improvements ourselves.

matteius avatar Jul 07 '23 03:07 matteius

I believe I added sufficient support in: https://github.com/pypa/pipenv/pull/6360 however it could use testing specifically of the py command.

matteius avatar Mar 20 '25 22:03 matteius