question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[EnvCommandError] returned on `poetry install` and `poetry env`

See original GitHub issue
  • 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

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:28
  • Comments:27 (5 by maintainers)

github_iconTop GitHub Comments

19reactions
dkrystkicommented, Sep 14, 2021

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

13reactions
LeGmaskcommented, Aug 29, 2020

I have the same issue, but removing virtualenv fix the thing…

Read more comments on GitHub >

github_iconTop Results From Across the Web

Poetry install fails with EnvCommandError: looks for version ...
The solution was to move the venv to the local project root. poetry config virtualenvs.in-project true poetry env remove python poetry install.
Read more >
EnvCommandError in Windows using Poetry - Random Wits
EnvCommandError in Windows using Poetry ... Poetry is a great dependency management tool in python. It's better than managing ... In cygwin, install...
Read more >
EnvCommandError - cannot get django tutorial to deploy
I created an environment variable to get render to use python ... Oct 16 08:24:48 PM Processing /opt/render/.cache/.python-poetry/cache/ ...
Read more >
Commands | master | Documentation | Poetry - Python ...
Commands You've already learned how to use the command-line interface to do some things. This chapter documents all the available commands.
Read more >
Configure a Poetry environment | PyCharm Documentation
You can declare the libraries your project depends on, and Poetry will install and update them for you. Project dependencies are recorded in...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found