python-poetry / python-poetry/poetry

Poetry 2.0.1 fails with "[WinError 5] Access is denied" ; Poetry 1.8.0 works great!

Open
#10,122 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

kind/bug status/triage
Dominant language
Python
Stars
34.3k
Forks
2.5k
Avg merge
2d 19h
Merged PRs (30d)
30

Description

Description

I was hoping to use poetry 2.0.1 to make use of the gui-script in order to run a window-less Python app but am having trouble getting that version to run.

I'm running Windows 11, Version 24h2 (OS Build 26100.2894) and I'm having trouble running the new 2.0.1 version of poetry (which I installed via pipx). I keep getting these [WinError 5] Access is denied errors, even for commands that don't seem like they should be accessing the file system.

Weirdly, when I downgrade to 1.8.0 everything works great.

Any ideas, advice, or thoughts on stuff to try would be greatly appreciated.

Here's my pyproject.toml file:

[tool.poetry]
name = "nvim-opener"
version = "0.1.0"
description = "Open files in NeoVim from Windows Explorer"
authors = ["Mike Panitz"]
license = "MIT"

[tool.poetry.dependencies]
python = ">=3.9,<3.12"  # Ensures compatibility by avoiding Python 3.12
pynvim = "^0.4.0"
pywin32 = "^306"
pygetwindow = "^0.0.9"  # Add this dependency

[tool.poetry.scripts]
nvim-open = "nvim_opener.main:run"

[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"

Here's a transcript of me not getting this to work πŸ™ƒ

> poetry --version
Poetry (version 2.0.1)
> poetry debug info

Poetry
Version: 2.0.1
Python:  3.12.1

[WinError 5] Access is denied
> poetry build

[WinError 5] Access is denied
> poetry build --no-cache

[WinError 5] Access is denied
> poetry cache clear --all PyPI
Delete 22 entries? (yes/no) [yes] yes
> poetry build

[WinError 5] Access is denied
> pipx install --force poetry==1.8.0
Installing to existing venv 'poetry'
  installed package poetry 1.8.0, installed using Python 3.12.1
  These apps are now globally available
    - poetry.exe
done! ✨ 🌟 ✨
> poetry build
Building nvim-opener (0.1.0)
  - Building sdist
  - Built nvim_opener-0.1.0.tar.gz
  - Building wheel
  - Built nvim_opener-0.1.0-py3-none-any.whl
>  
> pipx upgrade poetry
upgraded package poetry from 1.8.0 to 2.0.1 (location: C:\Users\michp\pipx\venvs\poetry)
> poetry build

[WinError 5] Access is denied
> poetry build -vvv
Trying to detect current active python executable as specified in the config.

  Stack trace:

  16  ~\pipx\venvs\poetry\Lib\site-packages\cleo\application.py:327 in run
       325β”‚
       326β”‚             try:
     β†’ 327β”‚                 exit_code = self._run(io)
       328β”‚             except BrokenPipeError:
       329β”‚                 # If we are piped to another process, it may close early and send a

  15  ~\pipx\venvs\poetry\Lib\site-packages\poetry\console\application.py:236 in _run
       234β”‚
       235β”‚         with directory(self._working_directory):
     β†’ 236β”‚             exit_code: int = super()._run(io)
       237β”‚
       238β”‚         return exit_code

  14  ~\pipx\venvs\poetry\Lib\site-packages\cleo\application.py:431 in _run
       429β”‚             io.input.interactive(interactive)
       430β”‚
     β†’ 431β”‚         exit_code = self._run_command(command, io)
       432β”‚         self._running_command = None
       433β”‚

  13  ~\pipx\venvs\poetry\Lib\site-packages\cleo\application.py:473 in _run_command
       471β”‚
       472β”‚         if error is not None:
     β†’ 473β”‚             raise error
       474β”‚
       475β”‚         return terminate_event.exit_code

  12  ~\pipx\venvs\poetry\Lib\site-packages\cleo\application.py:454 in _run_command
       452β”‚
       453β”‚         try:
     β†’ 454β”‚             self._event_dispatcher.dispatch(command_event, COMMAND)
       455β”‚
       456β”‚             if command_event.command_should_run():

  11  ~\pipx\venvs\poetry\Lib\site-packages\cleo\events\event_dispatcher.py:26 in dispatch
        24β”‚
        25β”‚         if listeners:
     β†’  26β”‚             self._do_dispatch(listeners, event_name, event)
        27β”‚
        28β”‚         return event

  10  ~\pipx\venvs\poetry\Lib\site-packages\cleo\events\event_dispatcher.py:85 in _do_dispatch
        83β”‚                 break
        84β”‚
     β†’  85β”‚             listener(event, event_name, self)
        86β”‚
        87β”‚     def _sort_listeners(self, event_name: str) -> None:

   9  ~\pipx\venvs\poetry\Lib\site-packages\poetry\console\application.py:346 in configure_env
       344β”‚
       345β”‚         env_manager = EnvManager(poetry, io=io)
     β†’ 346β”‚         env = env_manager.create_venv()
       347β”‚
       348β”‚         if env.is_venv() and io.is_verbose():

   8  ~\pipx\venvs\poetry\Lib\site-packages\poetry\utils\env\env_manager.py:382 in create_venv
       380β”‚
       381β”‚         cwd = self._poetry.file.path.parent
     β†’ 382β”‚         env = self.get(reload=True)
       383β”‚
       384β”‚         if not env.is_sane():

   7  ~\pipx\venvs\poetry\Lib\site-packages\poetry\utils\env\env_manager.py:206 in get
       204β”‚             return self._env
       205β”‚
     β†’ 206β”‚         python = Python.get_preferred_python(config=self._poetry.config, io=self._io)
       207β”‚         python_minor = python.minor_version.to_string()
       208β”‚

   6  ~\pipx\venvs\poetry\Lib\site-packages\poetry\utils\env\python_manager.py:120 in get_preferred_python
       118β”‚
       119β”‚         if not config.get("virtualenvs.use-poetry-python") and (
     β†’ 120β”‚             active_python := Python._detect_active_python(io)
       121β”‚         ):
       122β”‚             return cls(executable=active_python)

   5  ~\pipx\venvs\poetry\Lib\site-packages\poetry\utils\env\python_manager.py:90 in _detect_active_python
        88β”‚         )
        89β”‚
     β†’  90β”‚         executable = Python._full_python_path("python")
        91β”‚
        92β”‚         if executable is not None:

   4  ~\pipx\venvs\poetry\Lib\site-packages\poetry\utils\env\python_manager.py:72 in _full_python_path
        70β”‚         try:
        71β”‚             encoding = "locale" if sys.version_info >= (3, 10) else None
     β†’  72β”‚             executable = subprocess.check_output(
        73β”‚                 [path_python, "-c", "import sys; print(sys.executable)"],
        74β”‚                 text=True,

   3  C:\Program Files\Python312\Lib\subprocess.py:466 in check_output
        464β”‚         kwargs['input'] = empty
        465β”‚
     β†’  466β”‚     return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
        467β”‚                **kwargs).stdout
        468β”‚

   2  C:\Program Files\Python312\Lib\subprocess.py:548 in run
        546β”‚         kwargs['stderr'] = PIPE
        547β”‚
     β†’  548β”‚     with Popen(*popenargs, **kwargs) as process:
        549β”‚         try:
        550β”‚             stdout, stderr = process.communicate(input, timeout=timeout)

   1  C:\Program Files\Python312\Lib\subprocess.py:1026 in __init__
       1024β”‚                             encoding=encoding, errors=errors)
       1025β”‚
     β†’ 1026β”‚             self._execute_child(args, executable, preexec_fn, close_fds,
       1027β”‚                                 pass_fds, cwd, env,
       1028β”‚                                 startupinfo, creationflags, shell,

  PermissionError

  [WinError 5] Access is denied

  at C:\Program Files\Python312\Lib\subprocess.py:1538 in _execute_child
      1534β”‚             sys.audit("subprocess.Popen", executable, args, cwd, env)
      1535β”‚
      1536β”‚             # Start the process
      1537β”‚             try:
    β†’ 1538β”‚                 hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
      1539β”‚                                          # no special security
      1540β”‚                                          None, None,
      1541β”‚                                          int(not close_fds),
      1542β”‚                                          creationflags,    

> poetry env use "C:\Program Files\Python311\python.exe"

[WinError 5] Access is denied    
Workarounds

Downgrade to 1.8.0

Poetry Installation Method

pipx

Operating System

Windows 11

Poetry Version

2.0.1

Poetry Configuration
cache-dir = "C:\\Users\\michp\\AppData\\Local\\pypoetry\\Cache"
installer.max-workers = null
installer.no-binary = null
installer.only-binary = null
installer.parallel = true
installer.re-resolve = true
keyring.enabled = true
requests.max-retries = 0
solver.lazy-wheel = true
system-git-client = false
virtualenvs.create = true
virtualenvs.in-project = null
virtualenvs.options.always-copy = false
virtualenvs.options.no-pip = false
virtualenvs.options.system-site-packages = false
virtualenvs.path = "{cache-dir}\\virtualenvs"  # C:\Users\michp\AppData\Local\pypoetry\Cache\virtualenvs
virtualenvs.prompt = "{project_name}-py{python_version}"
virtualenvs.use-poetry-python = false
Python Sysconfig

py_sysconfig.txt

sysconfig.log
Paste the output of 'python -m sysconfig', over this line.
Example pyproject.toml
[tool.poetry]
name = "nvim-opener"
version = "0.1.0"
description = "Open files in NeoVim from Windows Explorer"
authors = ["Mike Panitz"]
license = "MIT"

[tool.poetry.dependencies]
python = ">=3.9,<3.12"  # Ensures compatibility by avoiding Python 3.12
pynvim = "^0.4.0"
pywin32 = "^306"
pygetwindow = "^0.0.9"  # Add this dependency

[tool.poetry.scripts]
nvim-open = "nvim_opener.main:run"

[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"
Poetry Runtime Logs
poetry-runtime.log
poetry build -vvv
Trying to detect current active python executable as specified in the config.

Stack trace:

16  ~\pipx\venvs\poetry\Lib\site-packages\cleo\application.py:327 in run
     325β”‚
     326β”‚             try:
   β†’ 327β”‚                 exit_code = self._run(io)
     328β”‚             except BrokenPipeError:
     329β”‚                 # If we are piped to another process, it may close early and send a

15  ~\pipx\venvs\poetry\Lib\site-packages\poetry\console\application.py:236 in _run
     234β”‚
     235β”‚         with directory(self._working_directory):
   β†’ 236β”‚             exit_code: int = super()._run(io)
     237β”‚
     238β”‚         return exit_code

14  ~\pipx\venvs\poetry\Lib\site-packages\cleo\application.py:431 in _run
     429β”‚             io.input.interactive(interactive)
     430β”‚
   β†’ 431β”‚         exit_code = self._run_command(command, io)
     432β”‚         self._running_command = None
     433β”‚

13  ~\pipx\venvs\poetry\Lib\site-packages\cleo\application.py:473 in _run_command
     471β”‚
     472β”‚         if error is not None:
   β†’ 473β”‚             raise error
     474β”‚
     475β”‚         return terminate_event.exit_code

12  ~\pipx\venvs\poetry\Lib\site-packages\cleo\application.py:454 in _run_command
     452β”‚
     453β”‚         try:
   β†’ 454β”‚             self._event_dispatcher.dispatch(command_event, COMMAND)
     455β”‚
     456β”‚             if command_event.command_should_run():

11  ~\pipx\venvs\poetry\Lib\site-packages\cleo\events\event_dispatcher.py:26 in dispatch
      24β”‚
      25β”‚         if listeners:
   β†’  26β”‚             self._do_dispatch(listeners, event_name, event)
      27β”‚
      28β”‚         return event

10  ~\pipx\venvs\poetry\Lib\site-packages\cleo\events\event_dispatcher.py:85 in _do_dispatch
      83β”‚                 break
      84β”‚
   β†’  85β”‚             listener(event, event_name, self)
      86β”‚
      87β”‚     def _sort_listeners(self, event_name: str) -> None:

 9  ~\pipx\venvs\poetry\Lib\site-packages\poetry\console\application.py:346 in configure_env
     344β”‚
     345β”‚         env_manager = EnvManager(poetry, io=io)
   β†’ 346β”‚         env = env_manager.create_venv()
     347β”‚
     348β”‚         if env.is_venv() and io.is_verbose():

 8  ~\pipx\venvs\poetry\Lib\site-packages\poetry\utils\env\env_manager.py:382 in create_venv
     380β”‚
     381β”‚         cwd = self._poetry.file.path.parent
   β†’ 382β”‚         env = self.get(reload=True)
     383β”‚
     384β”‚         if not env.is_sane():

 7  ~\pipx\venvs\poetry\Lib\site-packages\poetry\utils\env\env_manager.py:206 in get
     204β”‚             return self._env
     205β”‚
   β†’ 206β”‚         python = Python.get_preferred_python(config=self._poetry.config, io=self._io)
     207β”‚         python_minor = python.minor_version.to_string()
     208β”‚

 6  ~\pipx\venvs\poetry\Lib\site-packages\poetry\utils\env\python_manager.py:120 in get_preferred_python
     118β”‚
     119β”‚         if not config.get("virtualenvs.use-poetry-python") and (
   β†’ 120β”‚             active_python := Python._detect_active_python(io)
     121β”‚         ):
     122β”‚             return cls(executable=active_python)

 5  ~\pipx\venvs\poetry\Lib\site-packages\poetry\utils\env\python_manager.py:90 in _detect_active_python
      88β”‚         )
      89β”‚
   β†’  90β”‚         executable = Python._full_python_path("python")
      91β”‚
      92β”‚         if executable is not None:

 4  ~\pipx\venvs\poetry\Lib\site-packages\poetry\utils\env\python_manager.py:72 in _full_python_path
      70β”‚         try:
      71β”‚             encoding = "locale" if sys.version_info >= (3, 10) else None
   β†’  72β”‚             executable = subprocess.check_output(
      73β”‚                 [path_python, "-c", "import sys; print(sys.executable)"],
      74β”‚                 text=True,

 3  C:\Program Files\Python312\Lib\subprocess.py:466 in check_output
      464β”‚         kwargs['input'] = empty
      465β”‚
   β†’  466β”‚     return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
      467β”‚                **kwargs).stdout
      468β”‚

 2  C:\Program Files\Python312\Lib\subprocess.py:548 in run
      546β”‚         kwargs['stderr'] = PIPE
      547β”‚
   β†’  548β”‚     with Popen(*popenargs, **kwargs) as process:
      549β”‚         try:
      550β”‚             stdout, stderr = process.communicate(input, timeout=timeout)

 1  C:\Program Files\Python312\Lib\subprocess.py:1026 in __init__
     1024β”‚                             encoding=encoding, errors=errors)
     1025β”‚
   β†’ 1026β”‚             self._execute_child(args, executable, preexec_fn, close_fds,
     1027β”‚                                 pass_fds, cwd, env,
     1028β”‚                                 startupinfo, creationflags, shell,

PermissionError

[WinError 5] Access is denied

at C:\Program Files\Python312\Lib\subprocess.py:1538 in _execute_child
    1534β”‚             sys.audit("subprocess.Popen", executable, args, cwd, env)
    1535β”‚
    1536β”‚             # Start the process
    1537β”‚             try:
  β†’ 1538β”‚                 hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
    1539β”‚                                          # no special security
    1540β”‚                                          None, None,
    1541β”‚                                          int(not close_fds),
    1542β”‚                                          creationflags,    

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up β€” it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with poetry/utils/env/python_manager.py, especially _detect_active_python(), _full_python_path(), and the create_venv() call shown in the traceback. Reproduce poetry build -vvv and poetry env use on Windows 11 with Poetry 2.0.1; done means these commands no longer fail with [WinError 5] while the 1.8.0 behavior remains understood.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
build-system, devtools
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.