Skip to content

Pipenv unable to setup new environment when a path can not be read Permission Denied - WSL2 / Windows #4880

Closed
@bendog

Description

Issue description

When pipenv attempts to create a new environment, if there is a folder specified in PATH which is not accessible it will crash.
This is on WSL2, I also have a member of the team having this issue when using Pipenv + Windows natively

Expected result

Pipenv should create a new virtual environment.
Pipenv should ignore or warn about unreadable folders on PATH, without crashing.

Actual result

 ~/dev/test $ bat Pipfile 
───────┬────────────────────────────────────────────────────────────────────────────────────────────────────────────────
       │ File: Pipfile
───────┼────────────────────────────────────────────────────────────────────────────────────────────────────────────────
   1   │ [[source]]
   2   │ name = "pypi"
   3   │ url = "https://pypi.org/simple"
   4   │ verify_ssl = true
   5   │
   6   │ [dev-packages]
   7   │
   8   │ [packages]
   9   │
  10   │ [requires]
  11   │ python_version = "3.8"
───────┴────────────────────────────────────────────────────────────────────────────────────────────────────────────────
~/dev/test $ pipenv install
Traceback (most recent call last):
  File "/usr/local/bin/pipenv", line 8, in <module>
    sys.exit(cli())
  File "/usr/local/lib/python3.8/dist-packages/pipenv/vendor/click/core.py", line 1128, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python3.8/dist-packages/pipenv/vendor/click/core.py", line 1053, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python3.8/dist-packages/pipenv/vendor/click/core.py", line 1659, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/lib/python3.8/dist-packages/pipenv/vendor/click/core.py", line 1395, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python3.8/dist-packages/pipenv/vendor/click/core.py", line 754, in invoke
    return __callback(*args, **kwargs)
  File "/usr/local/lib/python3.8/dist-packages/pipenv/vendor/click/decorators.py", line 84, in new_func
    return ctx.invoke(f, obj, *args, **kwargs)
  File "/usr/local/lib/python3.8/dist-packages/pipenv/vendor/click/core.py", line 754, in invoke
    return __callback(*args, **kwargs)
  File "/usr/local/lib/python3.8/dist-packages/pipenv/cli/command.py", line 194, in install
    do_install(
  File "/usr/local/lib/python3.8/dist-packages/pipenv/core.py", line 1853, in do_install
    ensure_project(
  File "/usr/local/lib/python3.8/dist-packages/pipenv/core.py", line 517, in ensure_project
    ensure_virtualenv(
  File "/usr/local/lib/python3.8/dist-packages/pipenv/core.py", line 443, in ensure_virtualenv
    python = ensure_python(project, three=three, python=python)
  File "/usr/local/lib/python3.8/dist-packages/pipenv/core.py", line 335, in ensure_python
    path_to_python = find_a_system_python(python)
  File "/usr/local/lib/python3.8/dist-packages/pipenv/core.py", line 304, in find_a_system_python
    python_entry = find_python(finder, line)
  File "/usr/local/lib/python3.8/dist-packages/pipenv/utils.py", line 2199, in find_python
    result = finder.find_python_version(line)
  File "/usr/local/lib/python3.8/dist-packages/pipenv/vendor/pythonfinder/pythonfinder.py", line 288, in find_python_version
    return self.system_path.find_python_version(
  File "/usr/local/lib/python3.8/dist-packages/pipenv/vendor/pythonfinder/pythonfinder.py", line 120, in system_path
    self._system_path = self.create_system_path()
  File "/usr/local/lib/python3.8/dist-packages/pipenv/vendor/pythonfinder/pythonfinder.py", line 82, in create_system_path
    return pyfinder_path.SystemPath.create(
  File "/usr/local/lib/python3.8/dist-packages/pipenv/vendor/pythonfinder/models/path.py", line 667, in create
    {
  File "/usr/local/lib/python3.8/dist-packages/pipenv/vendor/pythonfinder/models/path.py", line 672, in <dictcomp>
    if p.exists()
  File "/usr/lib/python3.8/pathlib.py", line 1407, in exists
    self.stat()
  File "/usr/lib/python3.8/pathlib.py", line 1198, in stat
    return self._accessor.stat(self)
PermissionError: [Errno 13] Permission denied: '/mnt/c/Program Files (x86)/Adaptiva/AdaptivaClient/bin/x32'

Steps to replicate

See above.
If i remove that folder from my PATH then it will work.


Please run $ pipenv --support, and paste the results here. Don't put backticks (`) around it! The output already contains Markdown formatting.

~/dev/test $ pipenv --support
<details><summary>$ pipenv --support</summary>

Pipenv version: `'2021.11.23'`

Pipenv location: `'/usr/local/lib/python3.8/dist-packages/pipenv'`

Python location: `'/usr/bin/python3'`

Python installations found:

Traceback (most recent call last):
  File "/usr/local/bin/pipenv", line 8, in <module>
    sys.exit(cli())
  File "/usr/local/lib/python3.8/dist-packages/pipenv/vendor/click/core.py", line 1128, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python3.8/dist-packages/pipenv/vendor/click/core.py", line 1053, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python3.8/dist-packages/pipenv/vendor/click/core.py", line 1637, in invoke
    super().invoke(ctx)
  File "/usr/local/lib/python3.8/dist-packages/pipenv/vendor/click/core.py", line 1395, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python3.8/dist-packages/pipenv/vendor/click/core.py", line 754, in invoke
    return __callback(*args, **kwargs)
  File "/usr/local/lib/python3.8/dist-packages/pipenv/vendor/click/decorators.py", line 84, in new_func
    return ctx.invoke(f, obj, *args, **kwargs)
  File "/usr/local/lib/python3.8/dist-packages/pipenv/vendor/click/core.py", line 754, in invoke
    return __callback(*args, **kwargs)
  File "/usr/local/lib/python3.8/dist-packages/pipenv/vendor/click/decorators.py", line 26, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/usr/local/lib/python3.8/dist-packages/pipenv/cli/command.py", line 103, in cli
    get_pipenv_diagnostics(state.project)
  File "/usr/local/lib/python3.8/dist-packages/pipenv/help.py", line 31, in get_pipenv_diagnostics
    python_paths = finder.find_all_python_versions()
  File "/usr/local/lib/python3.8/dist-packages/pipenv/vendor/pythonfinder/pythonfinder.py", line 312, in find_all_python_versions
    python_version_dict = getattr(self.system_path, "python_version_dict", {})
  File "/usr/local/lib/python3.8/dist-packages/pipenv/vendor/pythonfinder/pythonfinder.py", line 120, in system_path
    self._system_path = self.create_system_path()
  File "/usr/local/lib/python3.8/dist-packages/pipenv/vendor/pythonfinder/pythonfinder.py", line 82, in create_system_path
    return pyfinder_path.SystemPath.create(
  File "/usr/local/lib/python3.8/dist-packages/pipenv/vendor/pythonfinder/models/path.py", line 667, in create
    {
  File "/usr/local/lib/python3.8/dist-packages/pipenv/vendor/pythonfinder/models/path.py", line 672, in <dictcomp>
    if p.exists()
  File "/usr/lib/python3.8/pathlib.py", line 1407, in exists
    self.stat()
  File "/usr/lib/python3.8/pathlib.py", line 1198, in stat
    return self._accessor.stat(self)
PermissionError: [Errno 13] Permission denied: '/mnt/c/Program Files (x86)/Adaptiva/AdaptivaClient/bin/x32'
  ~/dev/test 
APPLY FIX FOR PATH
~/dev/test $ pipenv --support
$ pipenv --support

Pipenv version: '2021.11.23'

Pipenv location: '/usr/local/lib/python3.8/dist-packages/pipenv'

Python location: '/usr/bin/python3'

Python installations found:

  • 3.10.0: /home/bendog/.pyenv/versions/3.10.0/bin/python3
  • 3.9.7: /home/bendog/.pyenv/versions/3.9.7/bin/python3.9
  • 3.9.0: /home/bendog/.pyenv/versions/3.9.0/bin/python3.9
  • 3.8.10: /usr/bin/python3.8
  • 3.8.10: /usr/bin/python3
  • 3.8.10: /usr/bin/python
  • 3.8.10: /bin/python3.8
  • 3.8.10: /bin/python3
  • 3.8.10: /bin/python
  • 3.7.9: /home/bendog/.pyenv/versions/3.7.9/bin/python3.7
  • 3.6.12: /home/bendog/.pyenv/versions/3.6.12/bin/python3
  • 2.7.18: /usr/bin/python2
  • 2.7.18: /usr/bin/python2.7
  • 2.7.18: /bin/python2
  • 2.7.18: /bin/python2.7

PEP 508 Information:

{'implementation_name': 'cpython',
 'implementation_version': '3.8.10',
 'os_name': 'posix',
 'platform_machine': 'x86_64',
 'platform_python_implementation': 'CPython',
 'platform_release': '4.19.128-microsoft-standard',
 'platform_system': 'Linux',
 'platform_version': '#1 SMP Tue Jun 23 12:58:10 UTC 2020',
 'python_full_version': '3.8.10',
 'python_version': '3.8',
 'sys_platform': 'linux'}

System environment variables:

  • HOSTTYPE
  • LANG
  • PATH
  • TERM
  • WSLENV
  • WT_SESSION
  • WT_PROFILE_ID
  • WSL_INTEROP
  • NAME
  • HOME
  • USER
  • LOGNAME
  • SHELL
  • WSL_DISTRO_NAME
  • SHLVL
  • PWD
  • OLDPWD
  • WSL_HOST
  • PYENV_ROOT
  • LESS
  • P9K_TTY
  • ZSH
  • PAGER
  • LSCOLORS
  • LS_COLORS
  • PYENV_SHELL
  • VIRTUAL_ENV_DISABLE_PROMPT
  • P9K_SSH
  • EDITOR
  • pipfile_dir
  • _
  • PIP_SHIMS_BASE_MODULE
  • PIP_DISABLE_PIP_VERSION_CHECK
  • PYTHONDONTWRITEBYTECODE
  • PIP_PYTHON_PATH
  • PYTHONFINDER_IGNORE_UNSUPPORTED

Pipenv–specific environment variables:

Debug–specific environment variables:

  • PATH: /home/bendog/.pyenv//bin:/home/bendog/.pyenv/shims:/home/bendog/.pyenv/bin:/home/bendog/.local/bin/:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/usr/lib/wsl/lib:/mnt/c/WINDOWS/CCM/:/mnt/c/WINDOWS/system32:/mnt/c/WINDOWS:/mnt/c/WINDOWS/System32/Wbem:/mnt/c/WINDOWS/System32/WindowsPowerShell/v1.0/:/mnt/c/WINDOWS/System32/OpenSSH/:/mnt/c/Program Files (x86)/Webex/Plugins:/mnt/c/ProgramData/chocolatey/bin:/mnt/c/Program Files/Amazon/AWSCLIV2/:/mnt/c/WINDOWS/system32:/mnt/c/WINDOWS:/mnt/c/WINDOWS/System32/Wbem:/mnt/c/WINDOWS/System32/WindowsPowerShell/v1.0/:/mnt/c/WINDOWS/System32/OpenSSH/:/mnt/c/Program Files/PowerShell/7/:/mnt/c/Program Files/Docker/Docker/resources/bin:/mnt/c/ProgramData/DockerDesktop/version-bin:/mnt/c/Users/fitzbe/scoop/shims:/mnt/c/Users/fitzbe/AppData/Local/Programs/Python/Python38/Scripts/:/mnt/c/Users/fitzbe/AppData/Local/Programs/Python/Python38/:/mnt/c/Users/fitzbe/AppData/Local/Programs/Microsoft VS Code/bin:/mnt/c/Users/fitzbe/AppData/Local/Programs/Git/cmd:/mnt/c/Users/fitzbe/AppData/Local/Programs/Hyper/resources/bin
  • SHELL: /usr/bin/zsh
  • EDITOR: nano
  • LANG: en_AU.UTF-8
  • PWD: /home/bendog/dev/test

Contents of Pipfile ('/home/bendog/dev/test/Pipfile'):

[[source]]
name = "pypi"
url = "https://pypi.org/simple"
verify_ssl = true

[dev-packages]

[packages]

[requires]
python_version = "3.8"

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions