poetry: `poetry self update --preview` leads to `[WinError 5] Access is denied: 'py3.7\\msgpack\\_cmsgpack.cp37-win_amd64.pyd'`

  • I am on the latest Poetry version.
  • I have searched the issues of this repo and believe that this is not a duplicate.
  • If an exception occurs when executing a command, I executed it again in debug mode (-vvv option).
  • OS version and name: Windows 10 pro, version 1909
  • Poetry version: 1.0.9
  • Link of a Gist with the contents of your pyproject.toml file: no project specific probelm

Issue

I use powershell and pyenv on windows with python 3.7. Python 3.7.5 is the newest version according to pyenv install -l Updating to the latest preview does not work as expected, I assumed poetry self update --preview would work. But see the log below, I can reproduce it every time with the same error. Installing/using poetry 1.0.9 works without issues. I guess it is similar to #1032 as shutil.py is involved in both problems, but the error is different.

Steps to reproduce

  1. install poetry with (Invoke-WebRequest -Uri https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py -UseBasicParsing).Content | python
  2. try to update with poetry self update --preview

Afterwards the poetry installation is corrupted and does not work anymore

Workaround powershell command

  1. delete the .poetry folder manually (located in user home directory)
  2. (Invoke-WebRequest -Uri https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py -UseBasicParsing).Content | python - --preview

Log that shows error

PS C:\Users\jahna> (Invoke-WebRequest -Uri https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py -UseBasicParsing).Content | python
Retrieving Poetry metadata

# Welcome to Poetry!

This will download and install the latest version of Poetry,
a dependency and package manager for Python.

It will add the `poetry` command to Poetry's bin directory, located at:

%USERPROFILE%\.poetry\bin

This path will then be added to your `PATH` environment variable by
modifying the `HKEY_CURRENT_USER/Environment/PATH` registry key.

You can uninstall at any time by executing this script with the --uninstall option,
and these changes will be reverted.

Installing version: 1.0.9
  - Downloading poetry-1.0.9-win32.tar.gz (10.72MB)

Poetry (1.0.9) is installed now. Great!

To get started you need Poetry's bin directory (%USERPROFILE%\.poetry\bin) in your `PATH`
environment variable. Future applications will automatically have the
correct environment, but you may need to restart your current shell.

PS C:\Users\jahna> poetry self update --preview -vvv
Updating to 1.1.0a3

[PermissionError]
[WinError 5] Access is denied: 'C:\\Users\\jahna\\.poetry\\lib\\poetry\\_vendor\\py3.7\\msgpack\\_cmsgpack.cp37-win_amd64.pyd'

Traceback (most recent call last):
  File "C:\Users\jahna\.poetry\lib\poetry\_vendor\py3.7\clikit\console_application.py", line 131, in run
  File "C:\Users\jahna\.poetry\lib\poetry\_vendor\py3.7\clikit\api\command\command.py", line 120, in handle
  File "C:\Users\jahna\.poetry\lib\poetry\_vendor\py3.7\clikit\api\command\command.py", line 171, in _do_handle
  File "C:\Users\jahna\.poetry\lib\poetry\_vendor\py3.7\cleo\commands\command.py", line 92, in wrap_handle
  File "C:\Users\jahna\.poetry\lib\poetry\console\commands\self\update.py", line 134, in handle
  File "C:\Users\jahna\.poetry\lib\poetry\console\commands\self\update.py", line 146, in update
  File "C:\Users\jahna\.pyenv\pyenv-win\versions\3.7.5-amd64\lib\shutil.py", line 516, in rmtree
    return _rmtree_unsafe(path, onerror)
  File "C:\Users\jahna\.pyenv\pyenv-win\versions\3.7.5-amd64\lib\shutil.py", line 395, in _rmtree_unsafe
    _rmtree_unsafe(fullname, onerror)
  File "C:\Users\jahna\.pyenv\pyenv-win\versions\3.7.5-amd64\lib\shutil.py", line 395, in _rmtree_unsafe
    _rmtree_unsafe(fullname, onerror)
  File "C:\Users\jahna\.pyenv\pyenv-win\versions\3.7.5-amd64\lib\shutil.py", line 395, in _rmtree_unsafe
    _rmtree_unsafe(fullname, onerror)
  [Previous line repeated 1 more time]
  File "C:\Users\jahna\.pyenv\pyenv-win\versions\3.7.5-amd64\lib\shutil.py", line 400, in _rmtree_unsafe
    onerror(os.unlink, fullname, sys.exc_info())
  File "C:\Users\jahna\.pyenv\pyenv-win\versions\3.7.5-amd64\lib\shutil.py", line 398, in _rmtree_unsafe
    os.unlink(fullname)
PermissionError: [WinError 5] Access is denied: 'C:\\Users\\jahna\\.poetry\\lib\\poetry\\_vendor\\py3.7\\msgpack\\_cmsgpack.cp37-win_amd64.pyd'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\jahna\.poetry\bin\poetry", line 18, in <module>
    main()
  File "C:\Users\jahna\.poetry\lib\poetry\console\__init__.py", line 5, in main
  File "C:\Users\jahna\.poetry\lib\poetry\_vendor\py3.7\clikit\console_application.py", line 139, in run
  File "C:\Users\jahna\.poetry\lib\poetry\_vendor\py3.7\clikit\ui\components\exception_trace.py", line 58, in render
  File "C:\Users\jahna\.poetry\lib\poetry\_vendor\py3.7\clikit\ui\components\exception_trace.py", line 63, in _render_traceback
  File "C:\Users\jahna\.poetry\lib\poetry\_vendor\py3.7\clikit\ui\components\exception_trace.py", line 75, in _format_traceback_frame
TypeError: 'NoneType' object is not subscriptable

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 18
  • Comments: 15 (5 by maintainers)

Most upvoted comments

Still having the same issue in 2021, had to uninstall and use the new install script to get the preview working:

(Invoke-WebRequest -Uri https://raw.githubusercontent.com/python-poetry/poetry/master/install-poetry.py -UseBasicParsing).Content | python - --preview

Not finding any definitive solution online and I followed the exact install steps, not sure how to fix it without a full re-install.

I’m having the same problem, even with the latest 1.1.0B2 version, I tested powershell, cmd and elevated cmd with the same error.

Updating to 1.1.0b1 Traceback (most recent call last): File “C:\Users\yifeili.poetry\lib\poetry_vendor\py3.8\clikit\console_application.py”, line 131, in run File “C:\Users\yifeili.poetry\lib\poetry_vendor\py3.8\clikit\api\command\command.py”, line 120, in handle File “C:\Users\yifeili.poetry\lib\poetry_vendor\py3.8\clikit\api\command\command.py”, line 171, in _do_handle File “C:\Users\yifeili.poetry\lib\poetry_vendor\py3.8\cleo\commands\command.py”, line 92, in wrap_handle File “C:\Users\yifeili.poetry\lib\poetry\console\commands\self\update.py”, line 128, in handle File “C:\Users\yifeili.poetry\lib\poetry\console\commands\self\update.py”, line 140, in update File “C:\Users\yifeili\AppData\Local\Programs\Python\Python38\lib\shutil.py”, line 737, in rmtree return _rmtree_unsafe(path, onerror) File “C:\Users\yifeili\AppData\Local\Programs\Python\Python38\lib\shutil.py”, line 610, in _rmtree_unsafe _rmtree_unsafe(fullname, onerror) File “C:\Users\yifeili\AppData\Local\Programs\Python\Python38\lib\shutil.py”, line 610, in _rmtree_unsafe _rmtree_unsafe(fullname, onerror) File “C:\Users\yifeili\AppData\Local\Programs\Python\Python38\lib\shutil.py”, line 610, in _rmtree_unsafe _rmtree_unsafe(fullname, onerror) [Previous line repeated 1 more time] File “C:\Users\yifeili\AppData\Local\Programs\Python\Python38\lib\shutil.py”, line 615, in _rmtree_unsafe onerror(os.unlink, fullname, sys.exc_info()) File “C:\Users\yifeili\AppData\Local\Programs\Python\Python38\lib\shutil.py”, line 613, in _rmtree_unsafe os.unlink(fullname) PermissionError: [WinError 5] Access is denied: ‘C:\Users\yifeili\.poetry\lib\poetry\_vendor\py3.8\msgpack\_cmsgpack.cp38-win_amd64.pyd’

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File “C:\Users\yifeili.poetry\bin\poetry”, line 18, in <module> main() File “C:\Users\yifeili.poetry\lib\poetry\console_init_.py”, line 5, in main File “C:\Users\yifeili.poetry\lib\poetry_vendor\py3.8\clikit\console_application.py”, line 142, in run File “C:\Users\yifeili.poetry\lib\poetry_vendor\py3.8\clikit\ui\components\exception_trace.py”, line 232, in render File “C:\Users\yifeili.poetry\lib\poetry_vendor\py3.8\clikit\ui\components\exception_trace.py”, line 251, in _render_exception ModuleNotFoundError: No module named ‘crashtest.inspector’

Just got this problem on Windows 11 - had to reinstall using the Powershell method too

Same here, just tried to update from 1.0.5 to 1.1.2 using poetry self update from bash console with admin rights and received ->

$ poetry self update
Updating to 1.1.2

[PermissionError]
[WinError 5] Access is denied: 'C:\\Users\\asalynskiy\\.poetry\\lib\\poetry\\_vendor\\py3.7\\msgpack\\_cmsgpack.cp37-win_amd64.pyd'

OS version and name: Windows 10 Pro, Build 19041 Poetry version: 1.0.5

UPD: It’s a shame, my issue seems to be connected to poetry .venv working in some other console. So if you also face this issue, check you don’t have poetry running somewhere else. 😅