poetry install gets CalledProcessError or EnvCommandError on Windows
See original GitHub issue- [ 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 Pro version 2004
- Poetry version: 1.0.10
- Link of a Gist with the contents of your pyproject.toml file:
Issue
- On a newly installed Windows 10 system.
- Install Python 3.7 using the Windows Store (author: Python Software Foundation)
- Install poetry using get-poetry.py script
- Add .poetry path to environment
- run poetry init and accept all defaults, except add Click package
- run poetry install and it fails with
CalledProcessError
- run poetry install again, and it fails with
EnvCommandError
C:\Users\jp2\Desktop\testpoetry>poetry install
Creating virtualenv testpoetry-MQk66TQ3-py3.7 in C:\Users\jp2\AppData\Local\pypoetry\Cache\virtualenvs
[CalledProcessError]
Command '['C:\\Users\\jp2\\AppData\\Local\\pypoetry\\Cache\\virtualenvs\\testpoetry-MQk66TQ3-py3.7\\Scripts\\python.exe', '-Im', 'ensurepip', '--upgrade', '--default-pip']' returned non-zero exit status 106.
C:\Users\jp2\Desktop\testpoetry>poetry install -vvv
[EnvCommandError]
Command ['C:\\Users\\jp2\\AppData\\Local\\pypoetry\\Cache\\virtualenvs\\testpoetry-MQk66TQ3-py3.7\\Scripts\\python.exe', '-'] errored with the following return code 1, and output:
The system cannot find the path specified.
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\jp2\.poetry\lib\poetry\_vendor\py3.7\clikit\console_application.py", line 131, in run
status_code = command.handle(parsed_args, io)
File "C:\Users\jp2\.poetry\lib\poetry\_vendor\py3.7\clikit\api\command\command.py", line 120, in handle
status_code = self._do_handle(args, io)
File "C:\Users\jp2\.poetry\lib\poetry\_vendor\py3.7\clikit\api\command\command.py", line 163, in _do_handle
self._dispatcher.dispatch(PRE_HANDLE, event)
File "C:\Users\jp2\.poetry\lib\poetry\_vendor\py3.7\clikit\api\event\event_dispatcher.py", line 22, in dispatch
self._do_dispatch(listeners, event_name, event)
File "C:\Users\jp2\.poetry\lib\poetry\_vendor\py3.7\clikit\api\event\event_dispatcher.py", line 89, in _do_dispatch
listener(event, event_name, self)
File "C:\Users\jp2\.poetry\lib\poetry\console\config\application_config.py", line 92, in set_env
env = env_manager.create_venv(io)
File "C:\Users\jp2\.poetry\lib\poetry\utils\env.py", line 490, in create_venv
env = self.get(reload=True)
File "C:\Users\jp2\.poetry\lib\poetry\utils\env.py", line 353, in get
return VirtualEnv(venv)
File "C:\Users\jp2\.poetry\lib\poetry\utils\env.py", line 1045, in __init__
self._base = Path(self.run('python', '-', input_=GET_BASE_PREFIX).strip())
File "C:\Users\jp2\.poetry\lib\poetry\utils\env.py", line 879, in run
return self._run(cmd, **kwargs)
File "C:\Users\jp2\.poetry\lib\poetry\utils\env.py", line 1112, in _run
return super(VirtualEnv, self)._run(cmd, **kwargs)
File "C:\Users\jp2\.poetry\lib\poetry\utils\env.py", line 916, in _run
raise EnvCommandError(e, input=input_)
C:\Users\jp2\Desktop\testpoetry>
This may be a clue. It seems python.exe cannot be copied from it’s install location. I’m thinking this is some kind of Windows Sandbox protection. Does poetry handle this correctly?
C:\Users\jp2\Desktop\testpoetry>where python
C:\Users\jp2\AppData\Local\Microsoft\WindowsApps\python.exe
C:\Users\jp2\Desktop\testpoetry>copy C:\Users\jp2\AppData\Local\Microsoft\WindowsApps\python.exe .
The file cannot be accessed by the system.
0 file(s) copied.
C:\Users\jp2\Desktop\testpoetry>dir C:\Users\jp2\AppData\Local\Microsoft\WindowsApps\python.exe
Volume in drive C is BOOTCAMP
Volume Serial Number is 0246-9FF7
Directory of C:\Users\jp2\AppData\Local\Microsoft\WindowsApps
07/29/2020 06:33 AM 0 python.exe
1 File(s) 0 bytes
0 Dir(s) 96,747,773,952 bytes free
Issue Analytics
- State:
- Created 3 years ago
- Reactions:5
- Comments:10 (1 by maintainers)
Top Results From Across the Web
EnvCommandError in Windows using Poetry - Random Wits
In cygwin, install poetry. $ curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py | python. Check the curent version.
Read more >Poetry install fails with EnvCommandError: looks for version ...
I had this same error because for some reason poetry install always failed to create a virtual enviroment path in %APPDATA% .
Read more >Replit does not allocate enough resources when installing ...
So for a while, I've been trying to install a python package called distilbert-punctuator ... python3 -m poetry add distilbert-punctuator Usin…
Read more >EnvCommandError - cannot get django tutorial to deploy
I created an environment variable to get render to use python 3.8.2 but when deploying I get the following EnvCommandError errors:.
Read more >Introduction | Documentation | Poetry - Python dependency ...
The previous get-poetry.py and install-poetry.py installers are deprecated. ... If you have installed Python through the Microsoft Store, replace py with ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Had the exact same trouble
After running
poetry install
in a project dir with some simplepyproject.toml
Solved it by editing
C:\Users\<USER>\.poetry\lib\poetry\utils\env.py
and commenting in method_run
of classEnv
:So I set
shell=False
for the upcomingsubprocess.run
call …Frankly, I really like the concept of
poetry
and give it a try so far but:On Windows it seems a bit untested. Spending around 2,5 hrs now just to get
poetry
installed and a poetry env created on Win 10.Normally I work on macOS, but for sure all common OS must be supported and on Windows it seems to be a bit of a hell.
Anyway, keep on going the good work! I will stick with it and see, how patient I’ll have to be 😃
How does poetry create its venv? The venv module should handle it fine, but it may be that it’s not using that.
In the Store package, the
WindowsApps\python.exe
that gets put on PATH isn’t the actual executable, but an OS-native redirector (not even a real file).sys.executable
will point to that, since it’s the path you need to use to re-run Python, butsys.prefix
contains the actual install. You can’t reliably copy these files out of here though, you’ll need the ones that are part of thevenv
module (which rely on apyvenv.cfg
to locate the actual install), or your own executable that knows how to launch the right thing.