poetry: [EnvCommandError] returned on `poetry install` and `poetry env`
-
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
-
Poetry version: 1.0.9
-
Link of a Gist with the contents of your pyproject.toml file: https://github.com/ernopp/smilebot/blob/master/pyproject.toml
Issue
Hi
There is an issue with my poetry installation
I am on version 1.0.9
C:\Users\ernest\dev\smilebot>poetry -V
Poetry version 1.0.9
My TOML appears correct
C:\Users\ernest\dev\smilebot>poetry check
All set!
But when I try to run poetry env info
or poetry install
(and same is true of many other commands I suspect) I get:
C:\Users\ernest\dev\smilebot>poetry install -vvv
[EnvCommandError]
Command ['C:\\Users\\ernest\\AppData\\Local\\pypoetry\\Cache\\virtualenvs\\shoponsmile-python-ovOS_Rxi-py3.8\\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\ernest\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\clikit\console_application.py", line 131, in run
status_code = command.handle(parsed_args, io)
File "C:\Users\ernest\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\clikit\api\command\command.py", line 120, in handle
status_code = self._do_handle(args, io)
File "C:\Users\ernest\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\clikit\api\command\command.py", line 163, in _do_handle
self._dispatcher.dispatch(PRE_HANDLE, event)
File "C:\Users\ernest\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\clikit\api\event\event_dispatcher.py", line 22, in dispatch
self._do_dispatch(listeners, event_name, event)
File "C:\Users\ernest\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\clikit\api\event\event_dispatcher.py", line 89, in _do_dispatch
listener(event, event_name, self)
File "C:\Users\ernest\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\poetry\console\config\application_config.py", line 89, in set_env
env = env_manager.create_venv(io)
File "C:\Users\ernest\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\poetry\utils\env.py", line 489, in create_venv
env = self.get(reload=True)
File "C:\Users\ernest\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\poetry\utils\env.py", line 352, in get
return VirtualEnv(venv)
File "C:\Users\ernest\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\poetry\utils\env.py", line 1022, in __init__
self._base = Path(self.run("python", "-", input_=GET_BASE_PREFIX).strip())
File "C:\Users\ernest\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\poetry\utils\env.py", line 856, in run
return self._run(cmd, **kwargs)
File "C:\Users\ernest\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\poetry\utils\env.py", line 1089, in _run
return super(VirtualEnv, self)._run(cmd, **kwargs)
File "C:\Users\ernest\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\poetry\utils\env.py", line 893, in _run
raise EnvCommandError(e, input=input_)
I can see and run the python executable at C:\Users\ernest\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\Local\pypoetry\Cache\virtualenvs\shoponsmile-python-ovOS_Rxi-py3.8\Scripts
…
This happens whether I install poetry via pip or via the curl command (tried both)
Any help appreciated
Thanks
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 30
- Comments: 28 (5 by maintainers)
Commits related to this issue
- fix: windowsとpython3.9でtestが通らないので修正。 参考: https://github.com/python-poetry/poetry/issues/2629#issuecomment-918725539 — committed to atu4403/env-paths by atu4403 3 years ago
- Remove caching from CI for Win + Python3.6 Issues: - https://github.com/python-poetry/poetry/issues/2629 - https://github.com/python-poetry/poetry/issues/4615 — committed to floatingpurr/sync_with_poetry by floatingpurr 3 years ago
- Remove caching in GH for Win runner See https://github.com/python-poetry/poetry/issues/2629#issuecomment-999647665 — committed to floatingpurr/sync_with_poetry by floatingpurr 3 years ago
I was having the same issue when caching .venv directory on a Windows runner. It turns out restoring cache breaks symlinks in the virtual env.
The solution is to first create virtualenv manually with:
python -m venv .venv --copies
Which does not rely on symlinks and then run:
poetry install
I have the same issue, but removing virtualenv fix the thing…
I solve my issue here changed the Python version. If I use Python 3.9.0 I have this problem, but if I use Python 3.8.6 (the last version of Python 3.8) all works ok! I’m in the Debian GNU/Linux system!
@floatingpurr yep, I gave PDM a try because of some of Poetry’s issues and limitations (not the place, but I can elaborate if needed). I was immediately hooked, and am exclusively using PDM now. It’s really good.
Simplest test fix on windows for me was as above: $env:POETRY_CACHE_DIR = ‘your-project-dir\.poetry_cache’
but it looks to me like a single global .poetry_cache directory would also work fine with poetry since it handles the naming… PS> [System.Environment]::SetEnvironmentVariable(‘POETRY_CACHE_DIR’, ‘C:\Users\MyUser.poetry_cache’, [System.EnvironmentVariableTarget]::User)
Then see: https://crapts.org/2020/05/11/use-poetry-for-python-dependency-management-with-visual-studio-code/
I’m also experiencing the same thing. I just installed python 3.9 from windows store and installed poetry version 1.1.4.
Here is the error message:
This is my
pyproject.toml
file just in case:Any help would be appreciated.
@1Mark The issue is that this is years old, the OP never provided sufficient detail to reproduce/check that this was fixed for them, and many users have chimed in with related but not the same (mostly configuration/usage) issues in the comments.
It’s hard enough to reason about a multiple years and version old issue report with no response or reproduction, let alone what has become a grab bag of “me too” that may or may not be the same root cause or even operating system.
It does create a higher barrier if someone runs into trouble, but this issue was already not helpful to both those experiencing this issue and those trying to solve it – without high quality issue reports it is very hard to fix bugs that are not obvious.
I ran into this issue trying to use Poetry with Windows + Python 3.6 and 3.9 in GitHub actions, where I have
actions/cache
configured to cache and restore Poetry’s virtualenv directory. After doing a little digging, I discovered that Poetry’s own GitHub Actions CI for Windows + Python 3.6 (which also caches the.venv
folder and restores it) is experiencing this same issue.Poetry’s CI workflow includes a step to nuke the virtualenv if it appears unhealthy after a cache restore, which looks to be how they work around it.
https://github.com/python-poetry/poetry/blob/527882380fd7aecd7c34922a7bc888226a5737ff/.github/workflows/main.yml#L75-L78
Here’s what I ended up with in CI. Took me the entire evening to make things work on Windows.
Can you make sure that the virtual environment in
C:\\Users\\ernest\\AppData\\Local\\pypoetry\\Cache\\virtualenvs\\shoponsmile-python-ovOS_Rxi-py3.8
was properly created?It looks like you’re having conflicting pythons running. Do you happen to either be in an existing virtual environment or using PyCharm by chance/bad luck?
Error at the top mentions: [‘C:\Users\ernest\AppData\Local\pypoetry\Cache\virtualenvs\shoponsmile-python-ovOS_Rxi-py3.8\Scripts\python.exe’, ‘-’]
Error in the stack mentions C:\Users\ernest\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38.…
Thank you this worked for me.
I really dislike this approach, an issue was reported against an old version, has all the details, and it wasn’t fixed yet it’s closed, then another user will have to open another ticket for the same problem. I appreciate the original reported version is no longer supported but if the issue exists in the latest poetry version it doesn’t make sense to close this ticket.
I’m having the same issue: