Poetry: Install throws CalledProcessError exit code 106 on windows 10

Created on 4 Jun 2020  路  6Comments  路  Source: python-poetry/poetry

  • [x] I am on the latest Poetry version.
  • [x] I have searched the issues of this repo and believe that this is not a duplicate.
  • [x] If an exception occurs when executing a command, I executed it again in debug mode (-vvv option).

  • OS version and name: Windows 10

  • Poetry version: 1.0.5
  • Link of a Gist with the contents of your pyproject.toml file: https://gist.github.com/johanvts/69ee6924868396984d2c3489e604b340

Issue

After doing a clean install I run:

poetry init

no problem, toml is created as linked.

poetry install
Creating virtualenv hyperpy-M0-5xabO-py3.8 in C:\Users\Johan\AppData\Local\pypoetry\Cachevirtualenvs
[CalledProcessError]
Command '['C:\Users\Johan\AppData\Local\pypoetry\Cache\virtualenvs\hyperpy-M0-5xabO-py3.8\Scripts\python.exe', '-Im', 'ensurepip', '--upgrade', '--default-pip']' returned non-zero exit status 106.

Subsequent attempts at poetry install gives:

PS C:\Users\Johan\hyperpy> poetry install -vvv

[EnvCommandError]
Command ['C:\Users\Johan\AppData\Local\pypoetry\Cache\virtualenvs\hyperpy-M0-5xabO-py3.8\Scripts\python.exe', '-'] errored with the following return code 1, and output:
'C:\Users\Johan\AppData\Local\pypoetry\Cachevirtualenvs\hyperpy-M0-5xabO-py3.8\Scripts\python.exe' is not recognized as an internal or external command,
operable program or batch file.
input was : import sys

if hasattr(sys, "real_prefix"):
print(sys.real_prefix)
elif hasattr(sys, "base_prefix"):
print(sys.base_prefix)
else:
print(sys.prefix)

Traceback (most recent call last):
File "C:\Users\Johan.poetry\lib\poetry_vendor\py3.8clikitconsole_application.py", line 131, in run
status_code = command.handle(parsed_args, io)
File "C:\Users\Johan.poetry\lib\poetry_vendor\py3.8clikitapicommandcommand.py", line 120, in handle
status_code = self._do_handle(args, io)
File "C:\Users\Johan.poetry\lib\poetry_vendor\py3.8clikitapicommandcommand.py", line 163, in _do_handle
self._dispatcher.dispatch(PRE_HANDLE, event)
File "C:\Users\Johan.poetry\lib\poetry_vendor\py3.8clikitapi\event\event_dispatcher.py", line 22, in dispatch
self._do_dispatch(listeners, event_name, event)
File "C:\Users\Johan.poetry\lib\poetry_vendor\py3.8clikitapi\event\event_dispatcher.py", line 89, in _do_dispatch
listener(event, event_name, self)
File "C:\Users\Johan.poetry\lib\poetryconsoleconfigapplication_config.py", line 89, in set_env
env = env_manager.create_venv(io)
File "C:\Users\Johan.poetry\lib\poetry\utils\env.py", line 489, in create_venv
env = self.get(reload=True)
File "C:\Users\Johan.poetry\lib\poetry\utils\env.py", line 352, in get
return VirtualEnv(venv)
File "C:\Users\Johan.poetry\lib\poetry\utils\env.py", line 1022, in __init__
self._base = Path(self.run("python", "-", input_=GET_BASE_PREFIX).strip())
File "C:\Users\Johan.poetry\lib\poetry\utils\env.py", line 856, in run
return self._run(cmd, *kwargs)
File "C:\Users\Johan.poetry\lib\poetry\utils\env.py", line 1089, in _run
return super(VirtualEnv, self)._run(cmd, *
kwargs)
File "C:\Users\Johan.poetry\lib\poetry\utils\env.py", line 893, in _run
raise EnvCommandError(e, input=input_)

I am aware of https://github.com/python-poetry/poetry/issues/1587
However Python 3.8 is installed through the store and works as expected:

PS C:\Users\Johan\hyperpy> where.exe python
C:\Users\Johan\AppData\Local\Microsoft\WindowsApps\python.exe
PS C:\Users\Johan\hyperpy> python
Python 3.8.3 (tags/v3.8.3:6f8c832, May 13 2020, 22:37:02) [MSC v.1924 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.

>

Bug Triage

Most helpful comment

I had this issue in both Powershell and cmd.exe, and symlinking worked indeed.

For those who don't how to symlink on Windows (i didn't have a clue), you need to use cmd (not Powershell) then do this:

cd %LocalAppData%
rmdir /q /s pypoetry
mklink /d %LocalAppData%\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\Local\pypoetry pypoetry

All 6 comments

I found out that poetry 1.0.8 does not work with the new windows terminal. It works without issues on cmd.

Still having issue in VSCode with 1.0.9

There seems to be something of a path mismatch happening here.

Poetry makes the initial copy of the python executable to %LocalAppData%\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\Local\pypoetry\..., but subsequently expects the environment to be located at %LocalAppData%\pypoetry\....

Symlinking %LocalAppData%\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\Local\pypoetry to %LocalAppData%\pypoetry seems to work around the issue for me.

There seems to be something of a path mismatch happening here.

Poetry makes the initial copy of the python executable to %LocalAppData%\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\Local\pypoetry\..., but subsequently expects the environment to be located at %LocalAppData%\pypoetry\....

Symlinking %LocalAppData%\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\Local\pypoetry to %LocalAppData%\pypoetry seems to work around the issue for me.

Yup, that was exactly my issue here! Symlinking solved this for me too.

I had this issue in both Powershell and cmd.exe, and symlinking worked indeed.

For those who don't how to symlink on Windows (i didn't have a clue), you need to use cmd (not Powershell) then do this:

cd %LocalAppData%
rmdir /q /s pypoetry
mklink /d %LocalAppData%\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\Local\pypoetry pypoetry

I had this issue in both Powershell and cmd.exe, and symlinking worked indeed.

For those who don't how to symlink on Windows (i didn't have a clue), you need to use cmd (not Powershell) then do this:

cd %LocalAppData%
rmdir /q /s pypoetry
mklink /d %LocalAppData%\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\Local\pypoetry pypoetry

Thanks @hay!

Be aware that the order of target and link is reversed!
It should be like

mklink /d pypoetry %LocalAppData%\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\Local\pypoetry
Was this page helpful?
0 / 5 - 0 ratings