Poetry: Poetry install command fails - EnvCommandError

Created on 2 Apr 2020  路  5Comments  路  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: macOS Catalina 10.15.3
  • Poetry version: 1.05
  • fish version: 3.1.0

    Issue

After checking the toml file with poetry check which was fine.
Attempting to install gave the below error.
(Note also trying poetry env use 3 gave the same error as does poetry env info.
Using python3 works fine and loads the REPL)

[EnvCommandError]
Command ['/Users/yunti/Library/Caches/pypoetry/virtualenvs/switcher5-8hLu6-cI-py3.7/bin/python', '-'] errored with the following return code -6, and output:
dyld: Library not loaded: @executable_path/../Python3
  Referenced from: /Users/yunti/Library/Caches/pypoetry/virtualenvs/switcher5-8hLu6-cI-py3.7/bin/python
  Reason: image not found
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 "/Users/yunti/.poetry/lib/poetry/_vendor/py2.7/clikit/console_application.py", line 131, in run
    status_code = command.handle(parsed_args, io)
  File "/Users/yunti/.poetry/lib/poetry/_vendor/py2.7/clikit/api/command/command.py", line 120, in handle
    status_code = self._do_handle(args, io)
  File "/Users/yunti/.poetry/lib/poetry/_vendor/py2.7/clikit/api/command/command.py", line 163, in _do_handle
    self._dispatcher.dispatch(PRE_HANDLE, event)
  File "/Users/yunti/.poetry/lib/poetry/_vendor/py2.7/clikit/api/event/event_dispatcher.py", line 22, in dispatch
    self._do_dispatch(listeners, event_name, event)
  File "/Users/yunti/.poetry/lib/poetry/_vendor/py2.7/clikit/api/event/event_dispatcher.py", line 89, in _do_dispatch
    listener(event, event_name, self)
  File "/Users/yunti/.poetry/lib/poetry/console/config/application_config.py", line 89, in set_env
    env = env_manager.create_venv(io)
  File "/Users/yunti/.poetry/lib/poetry/utils/env.py", line 657, in create_venv
    return VirtualEnv(venv)
  File "/Users/yunti/.poetry/lib/poetry/utils/env.py", line 1022, in __init__
    self._base = Path(self.run('python', '-', input_=GET_BASE_PREFIX).strip())
  File "/Users/yunti/.poetry/lib/poetry/utils/env.py", line 856, in run
    return self._run(cmd, **kwargs)
  File "/Users/yunti/.poetry/lib/poetry/utils/env.py", line 1089, in _run
    return super(VirtualEnv, self)._run(cmd, **kwargs)
  File "/Users/yunti/.poetry/lib/poetry/utils/env.py", line 893, in _run
    raise EnvCommandError(e, input=input_)
Bug

Most helpful comment

I also encountered this after brew install another package (which updated my python version).
I fixed this by

  1. rm -rf /Users/(user)/Library/Caches/pypoetry/virtualenvs/yourvirtualenv/
  2. poetry install
    馃榾 This should fix your problem

All 5 comments

Solved by running brew doctor and following the instructions to resolve the python links with brew link.

Perhaps an error output to the user to possible check that or to clarify the issue is with the python istallation may help possible repeats of the issue.

I also encountered this after brew install another package (which updated my python version).
I fixed this by

  1. rm -rf /Users/(user)/Library/Caches/pypoetry/virtualenvs/yourvirtualenv/
  2. poetry install
    馃榾 This should fix your problem

I have a brand new mac with macOS Catalina 10.15.4 and I have not installed any python project before.

I got the same error when running it the first time poetry install, brew doctor did not give any errors.

The issue got solved after I installed python 3 using brew install python3 just adding it for reference.

Yeah the same problem here, what I did was install brew and then brew install python3 just with those steps I could run poetry install without problem.

I also encountered this after brew install another package (which updated my python version).
I fixed this by

  1. rm -rf /Users/(user)/Library/Caches/pypoetry/virtualenvs/yourvirtualenv/
  2. poetry install
    馃榾 This should fix your problem

Thanks for this! This helped solve my problem after I did a brew update a couple of days ago.

Was this page helpful?
0 / 5 - 0 ratings