pipenv icon indicating copy to clipboard operation
pipenv copied to clipboard

Fresh creation of pipenv creates and fails immediately in Windows

Open gigatesseract opened this issue 10 months ago • 6 comments

Be sure to check the existing issues (both open and closed!), and make sure you are running the latest version of Pipenv.

Check the diagnose documentation for common issues before posting! We may close your issue if it is very similar to one of them. Please be considerate, or be on your way.

Make sure to mention your debugging experience if the documented solution failed.

Issue description

Unable to create a virtualenv using pipenv

Expected result

To create a virtualenv successfully

Actual result

RuntimeError

Steps to replicate

  • Create an empty directory
  • Install latest pipenv
  • Try creating an environment (Eg: pipenv --python 3.10)
  • No Pipfile
PS C:\Users\nprav\repro-pipenv> pipenv --version       
pipenv, version 2023.10.3
PS C:\Users\nprav\repro-pipenv> virtualenv --version   
virtualenv 20.24.5 from C:/msys64/mingw64/lib/python3.10/site-packages/virtualenv/__init__.py
PS C:\Users\nprav\repro-pipenv> pipenv --python 3.10
Creating a virtualenv for this project...
Pipfile: C:/Users/nprav/repro-pipenv/Pipfile
Using C:/msys64/mingw64/bin/python3.exe (3.10.11) to create virtualenv...
[=   ] Creating virtual environment...created virtual environment CPython3.10.11.final.0-64 in 735ms
  creator CPython3Windows(dest=C:/Users/nprav/.virtualenvs/repro-pipenv-rk4kLvXU, clear=False, no_vcs_ignore=False, global=False)
  seeder FromAppData(download=False, pip=bundle, setuptools=bundle, wheel=bundle, via=copy, app_data_dir=C:/Users/nprav/AppData/Local/pypa/virtualenv)
    added seed packages: pip==23.2.1, setuptools==68.2.2, wheel==0.41.2
  activators BashActivator,BatchActivator,FishActivator,NushellActivator,PowerShellActivator,PythonActivator

Successfully created virtual environment!
Virtualenv location: C:/Users/nprav/.virtualenvs/repro-pipenv-rk4kLvXU
Traceback (most recent call last):
  File "C:/msys64/mingw64/lib/python3.10/runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "C:/msys64/mingw64/lib/python3.10/runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "C:/msys64/mingw64/bin/pipenv.exe/__main__.py", line 7, in <module>
    # when invoked as python -m pip <command>
  File "C:/msys64/mingw64/lib/python3.10/site-packages/pipenv/vendor/click/core.py", line 1130, in __call__
    return self.main(*args, **kwargs)
  File "C:/msys64/mingw64/lib/python3.10/site-packages/pipenv/cli/options.py", line 58, in main
    return super().main(*args, **kwargs, windows_expand_args=False)
  File "C:/msys64/mingw64/lib/python3.10/site-packages/pipenv/vendor/click/core.py", line 1055, in main
    rv = self.invoke(ctx)
  File "C:/msys64/mingw64/lib/python3.10/site-packages/pipenv/vendor/click/core.py", line 1635, in invoke
    rv = super().invoke(ctx)
  File "C:/msys64/mingw64/lib/python3.10/site-packages/pipenv/vendor/click/core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "C:/msys64/mingw64/lib/python3.10/site-packages/pipenv/vendor/click/core.py", line 760, in invoke
    return __callback(*args, **kwargs)
  File "C:/msys64/mingw64/lib/python3.10/site-packages/pipenv/vendor/click/decorators.py", line 84, in new_func
    return ctx.invoke(f, obj, *args, **kwargs)
  File "C:/msys64/mingw64/lib/python3.10/site-packages/pipenv/vendor/click/core.py", line 760, in invoke
    return __callback(*args, **kwargs)
  File "C:/msys64/mingw64/lib/python3.10/site-packages/pipenv/vendor/click/decorators.py", line 26, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "C:/msys64/mingw64/lib/python3.10/site-packages/pipenv/cli/command.py", line 181, in cli
    ensure_project(
  File "C:/msys64/mingw64/lib/python3.10/site-packages/pipenv/utils/project.py", line 80, in ensure_project
    ensure_pipfile(
  File "C:/msys64/mingw64/lib/python3.10/site-packages/pipenv/utils/pipfile.py", line 73, in ensure_pipfile
    project._which("python")
  File "C:/msys64/mingw64/lib/python3.10/site-packages/pipenv/project.py", line 1411, in _which
    raise RuntimeError("location not created nor specified")
RuntimeError: location not created nor specified
PS C:\Users\nprav\repro-pipenv> 

$ pipenv --support

Pipenv version: '2023.10.3'

Pipenv location: 'C:/msys64/mingw64/lib/python3.10/site-packages/pipenv'

Python location: 'C:/msys64/mingw64/bin/python3.exe'

OS Name: 'nt'

User pip version: '23.2.1'

user Python installations found:

PEP 508 Information:

{'implementation_name': 'cpython',
 'implementation_version': '3.10.11',
 'os_name': 'nt',
 'platform_machine': 'AMD64',
 'platform_python_implementation': 'CPython',
 'platform_release': '10',
 'platform_system': 'Windows',
 'platform_version': '10.0.22621',
 'python_full_version': '3.10.11',
 'python_version': '3.10',
 'sys_platform': 'win32'}

System environment variables:

  • ACLOCAL_PATH
  • ALLUSERSPROFILE
  • APPDATA
  • ASL.LOG
  • CHROME_CRASHPAD_PIPE_NAME
  • COMMONPROGRAMFILES
  • COMMONPROGRAMFILES(X86)
  • COMMONPROGRAMW6432
  • COMPUTERNAME
  • COMSPEC
  • CONFIG_SITE
  • DISPLAY
  • DRIVERDATA
  • EFC_8620
  • EXEPATH
  • HOME
  • HOMEDRIVE
  • HOMEPATH
  • HOSTNAME
  • INFOPATH
  • LC_CTYPE
  • LOCALAPPDATA
  • LOGONSERVER
  • MANPATH
  • MINGW_CHOST
  • MINGW_PACKAGE_PREFIX
  • MINGW_PREFIX
  • MOZ_CRASHREPORTER_DATA_DIRECTORY
  • MOZ_CRASHREPORTER_EVENTS_DIRECTORY
  • MOZ_CRASHREPORTER_PING_DIRECTORY
  • MOZ_CRASHREPORTER_RESTART_ARG_0
  • MOZ_CRASHREPORTER_STRINGS_OVERRIDE
  • MSYS
  • MSYSTEM
  • MSYSTEM_CARCH
  • MSYSTEM_CHOST
  • MSYSTEM_PREFIX
  • NUMBER_OF_PROCESSORS
  • OLDPWD
  • ONEDRIVE
  • ONEDRIVECONSUMER
  • ORIGINAL_PATH
  • ORIGINAL_TEMP
  • ORIGINAL_TMP
  • ORIGINAL_XDG_CURRENT_DESKTOP
  • OS
  • PATH
  • PATHEXT
  • PKG_CONFIG_PATH
  • PKG_CONFIG_SYSTEM_INCLUDE_PATH
  • PKG_CONFIG_SYSTEM_LIBRARY_PATH
  • PLINK_PROTOCOL
  • PROCESSOR_ARCHITECTURE
  • PROCESSOR_IDENTIFIER
  • PROCESSOR_LEVEL
  • PROCESSOR_REVISION
  • PROGRAMDATA
  • PROGRAMFILES
  • PROGRAMFILES(X86)
  • PROGRAMW6432
  • PSMODULEPATH
  • PUBLIC
  • PWD
  • SESSIONNAME
  • SHELL
  • SHIM_MCCOMPAT
  • SHLVL
  • SSH_ASKPASS
  • SYSTEMDRIVE
  • SYSTEMROOT
  • TEMP
  • TERM
  • TERM_PROGRAM
  • TERM_PROGRAM_VERSION
  • TMP
  • TMPDIR
  • USERDOMAIN
  • USERDOMAIN_ROAMINGPROFILE
  • USERNAME
  • USERPROFILE
  • WINDIR
  • ZES_ENABLE_SYSMAN
  • _
  • __PSLOCKDOWNPOLICY
  • LANG
  • COLORTERM
  • GIT_ASKPASS
  • VSCODE_GIT_ASKPASS_NODE
  • VSCODE_GIT_ASKPASS_EXTRA_ARGS
  • VSCODE_GIT_ASKPASS_MAIN
  • VSCODE_GIT_IPC_HANDLE
  • PIP_DISABLE_PIP_VERSION_CHECK
  • PYTHONDONTWRITEBYTECODE
  • PYTHONFINDER_IGNORE_UNSUPPORTED

Pipenv?specific environment variables:

Debug?specific environment variables:

  • PATH: C:\Users\nprav\bin;C:\Program Files\Git\mingw64\bin;C:\Program Files\Git\usr\local\bin;C:\Program Files\Git\usr\bin;C:\Program Files\Git\usr\bin;C:\Program Files\Git\mingw64\bin;C:\Program Files\Git\usr\bin;C:\Users\nprav\bin;C:\Program Files\Mozilla Firefox;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0;C:\Windows\System32\OpenSSH;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files\NVIDIA Corporation\NVIDIA NvDLISR;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0;C:\WINDOWS\System32\OpenSSH;C:\msys64\mingw64\bin;C:\Ruby31-x64\bin;C:\Users\nprav\AppData\Local\Microsoft\WindowsApps;C:\Users\nprav\AppData\Local\Programs\Microsoft VS Code\bin;C:\Program Files\Git\usr\bin\vendor_perl;C:\Program Files\Git\usr\bin\core_perl;C:\msys64\mingw64\bin\
  • SHELL: C:\Program Files\Git\usr\bin\bash.exe
  • LANG: en_US.UTF-8
  • PWD: C:/Users/nprav/hacktoberfest/first-contributions

gigatesseract avatar Oct 15 '23 15:10 gigatesseract

The which command tries to check if the file Scripts/activate.bat exists or not, if Windows.

However, the bat file is in bin directory itself

PS C:\Users\nprav\repro-pipenv> cd  C:/Users/nprav/.virtualenvs/repro-pipenv-rk4kLvXU
PS C:\Users\nprav\.virtualenvs\repro-pipenv-rk4kLvXU> ls


    Directory: C:\Users\nprav\.virtualenvs\repro-pipenv-rk4kLvXU


Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
d-----        15-10-2023     21:02                bin
d-----        15-10-2023     21:02                lib
-a----        15-10-2023     21:02             42 .gitignore
-a----        15-10-2023     21:02             27 .project
-a----        15-10-2023     21:02            295 pyvenv.cfg


PS C:\Users\nprav\.virtualenvs\repro-pipenv-rk4kLvXU> ls bin


    Directory: C:\Users\nprav\.virtualenvs\repro-pipenv-rk4kLvXU\bin


Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
-a----        15-10-2023     21:02           2277 activate
-a----        15-10-2023     21:02           1075 activate.bat
-a----        15-10-2023     21:02           3107 activate.fish
-a----        15-10-2023     21:02           2792 activate.nu
-a----        15-10-2023     21:02           1674 activate.ps1
-a----        15-10-2023     21:02           1349 activate_this.py
-a----        15-10-2023     21:02            537 deactivate.bat
-a----        15-10-2023     21:02         108423 pip-3.10.exe
-a----        15-10-2023     21:02         108423 pip.exe
-a----        15-10-2023     21:02         108423 pip3.10.exe
-a----        15-10-2023     21:02         108423 pip3.exe
-a----        15-10-2023     21:02             24 pydoc.bat
-a----        15-10-2023     21:02          99407 python.exe
-a----        15-10-2023     21:02          97871 pythonw.exe
-a----        15-10-2023     21:02         108410 wheel-3.10.exe
-a----        15-10-2023     21:02         108410 wheel.exe
-a----        15-10-2023     21:02         108410 wheel3.10.exe
-a----        15-10-2023     21:02         108410 wheel3.exe

gigatesseract avatar Oct 15 '23 15:10 gigatesseract

Did some more digging, realised pipenv creates virtual by running the virtualenv create command in CLI.

It was a but difficult to identify the source code that actually creates the files, but I saw one of the tests

https://github.com/pypa/virtualenv/blob/97b3060c0c679d382129224b8bde7565c7344cb7/tests/unit/create/test_creator.py#L646

It checks only if bin is created, doesnt do any window specific nt checks

Let me know if this should be a virtualenv issue or pipenv

gigatesseract avatar Oct 15 '23 16:10 gigatesseract

Just wondering, and its different from your virtualenv question, I'd have to dig more in that, but does this update to pythonfinder solve what you are seeing: https://github.com/pypa/pipenv/pull/5986

matteius avatar Oct 20 '23 01:10 matteius

@matteius I am not sure, I dont see any references to updating Scripts with bin I think it will not be solved. Any way for me to check for sure?

gigatesseract avatar Oct 25 '23 10:10 gigatesseract

Well from my perspective, I use pipenv in windows all the time -- I recall such a similar issue in the past but I thought it was solved by upgrading virtualenv and re-creating old virtualenvs. The new version has been published to pypi so you can upgrade pipenv as well.

matteius avatar Oct 25 '23 11:10 matteius

I still face the issue with latest versions of pipenv.

PS C:\Users\nprav\repro-pipenv> virtualenv --version
virtualenv 20.24.6 from C:\msys64\mingw64\lib\python3.10\site-packages\virtualenv\__init__.py
PS C:\Users\nprav\repro-pipenv> pipenv --version
pipenv, version 2023.10.24
PS C:\Users\nprav\repro-pipenv> pipenv --python 3.10 
Creating a virtualenv for this project...
Pipfile: C:\Users\nprav\repro-pipenv\Pipfile
Using C:/msys64/mingw64/bin/python3.exe (3.10.11) to create virtualenv...
[  ==] Creating virtual environment...created virtual environment CPython3.10.11.final.0-64 in 459ms
  creator CPython3Windows(dest=C:\Users\nprav\.virtualenvs\repro-pipenv-Z03S2cw0, clear=False, no_vcs_ignore=False, global=False)
  seeder FromAppData(download=False, pip=bundle, setuptools=bundle, wheel=bundle, via=copy, app_data_dir=C:\Users\nprav\AppData\Local\pypa\virtualenv)
    added seed packages: pip==23.2.1, setuptools==68.2.2, wheel==0.41.2
  activators BashActivator,BatchActivator,FishActivator,NushellActivator,PowerShellActivator,PythonActivator

Successfully created virtual environment!
Virtualenv location: C:\Users\nprav\.virtualenvs\repro-pipenv-Z03S2cw0                                                       
Traceback (most recent call last):
  File "C:\msys64\mingw64\lib\python3.10\runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "C:\msys64\mingw64\lib\python3.10\runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "C:\msys64\mingw64\bin\pipenv.exe\__main__.py", line 7, in <module>
    # when invoked as python -m pip <command>
  File "C:\msys64\mingw64\lib\python3.10\site-packages\pipenv\vendor\click\core.py", line 1157, in __call__
    return self.main(*args, **kwargs)
  File "C:\msys64\mingw64\lib\python3.10\site-packages\pipenv\cli\options.py", line 58, in main
    return super().main(*args, **kwargs, windows_expand_args=False)
  File "C:\msys64\mingw64\lib\python3.10\site-packages\pipenv\vendor\click\core.py", line 1078, in main
    rv = self.invoke(ctx)
  File "C:\msys64\mingw64\lib\python3.10\site-packages\pipenv\vendor\click\core.py", line 1666, in invoke
    rv = super().invoke(ctx)
  File "C:\msys64\mingw64\lib\python3.10\site-packages\pipenv\vendor\click\core.py", line 1434, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "C:\msys64\mingw64\lib\python3.10\site-packages\pipenv\vendor\click\core.py", line 783, in invoke
    return __callback(*args, **kwargs)
  File "C:\msys64\mingw64\lib\python3.10\site-packages\pipenv\vendor\click\decorators.py", line 92, in new_func
    return ctx.invoke(f, obj, *args, **kwargs)
  File "C:\msys64\mingw64\lib\python3.10\site-packages\pipenv\vendor\click\core.py", line 783, in invoke
    return __callback(*args, **kwargs)
  File "C:\msys64\mingw64\lib\python3.10\site-packages\pipenv\vendor\click\decorators.py", line 33, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "C:\msys64\mingw64\lib\python3.10\site-packages\pipenv\cli\command.py", line 181, in cli
    ensure_project(
  File "C:\msys64\mingw64\lib\python3.10\site-packages\pipenv\utils\project.py", line 80, in ensure_project
    ensure_pipfile(
  File "C:\msys64\mingw64\lib\python3.10\site-packages\pipenv\utils\pipfile.py", line 73, in ensure_pipfile
    project._which("python")
  File "C:\msys64\mingw64\lib\python3.10\site-packages\pipenv\project.py", line 1425, in _which
    raise RuntimeError("location not created nor specified")
RuntimeError: location not created nor specified
PS C:\Users\nprav\repro-pipenv> 

gigatesseract avatar Oct 26 '23 19:10 gigatesseract