poetry: Installation fails for some package with error on IsolatedEnv instanciation

  • Poetry version: Poetry (version 1.6.1)

  • Python version: Python: 3.11.5

  • OS version and name: Arch Linux

  • pyproject.toml: https://gist.github.com/nanoy42/20a7742335290a2f60341a7dff9cdb7f (almost default)

  • I am on the latest stable Poetry version, installed using a recommended method.

  • I have searched the issues of this repo and believe that this is not a duplicate.

  • I have consulted the FAQ and blog for any relevant entries or release notes.

  • If an exception occurs when executing a command, I executed it again in debug mode (-vvv option) and have included the output below.

Issue

I am experiencing the following issue when trying to install some packages: it fails with the error Can’t instantiate abstract class IsolatedEnv with abstract methods make_extra_environ, python_executable

Full stack trace:

Loading configuration file /home/nanoy/.config/pypoetry/config.toml
Using virtualenv: /home/nanoy/.cache/pypoetry/virtualenvs/test-eFcMuGbA-py3.11
Cloning 'https://github.com/nanoy42/falcon' using system git client

Updating dependencies
Resolving dependencies...
   1: fact: test is 0.1.0
   1: derived: test
   1: fact: test depends on falcon (0.9.2)
   1: selecting test (0.1.0)
   1: derived: falcon (0.9.2) @ git+https://github.com/nanoy42/falcon
   1: fact: falcon (0.9.2) depends on numpy (^1.22.3)
   1: fact: falcon (0.9.2) depends on pycryptodome (^3.16.0)
   1: selecting falcon (0.9.2 906b225)
   1: derived: pycryptodome (>=3.16.0,<4.0.0)
   1: derived: numpy (>=1.22.3,<2.0.0)
No suitable keyring backend found
No suitable keyring backends were found
Keyring is not available, credentials will be stored and retrieved from configuration files as plaintext.
Creating new session for pypi.org
[urllib3.connectionpool] Starting new HTTPS connection (1): pypi.org:443
[urllib3.connectionpool] https://pypi.org:443 "GET /simple/pycryptodome/ HTTP/1.1" 304 0
[filelock] Attempting to acquire lock 139921706129360 on /home/nanoy/.cache/pypoetry/cache/repositories/PyPI/_http/e/1/6/a/f/e16aff1a3f121e44b7a7d104d7cf73a008a55e8e7b9ee657c267f5a7.lock
[filelock] Lock 139921706129360 acquired on /home/nanoy/.cache/pypoetry/cache/repositories/PyPI/_http/e/1/6/a/f/e16aff1a3f121e44b7a7d104d7cf73a008a55e8e7b9ee657c267f5a7.lock
[filelock] Attempting to release lock 139921706129360 on /home/nanoy/.cache/pypoetry/cache/repositories/PyPI/_http/e/1/6/a/f/e16aff1a3f121e44b7a7d104d7cf73a008a55e8e7b9ee657c267f5a7.lock
[filelock] Lock 139921706129360 released on /home/nanoy/.cache/pypoetry/cache/repositories/PyPI/_http/e/1/6/a/f/e16aff1a3f121e44b7a7d104d7cf73a008a55e8e7b9ee657c267f5a7.lock
Source (PyPI): 4 packages found for pycryptodome >=3.16.0,<4.0.0
[urllib3.connectionpool] https://pypi.org:443 "GET /simple/numpy/ HTTP/1.1" 304 0
[filelock] Attempting to acquire lock 139921703037456 on /home/nanoy/.cache/pypoetry/cache/repositories/PyPI/_http/c/c/1/3/3/cc133da5701a066bc3777b2575e0daa601596f19871db4608ca98b97.lock
[filelock] Lock 139921703037456 acquired on /home/nanoy/.cache/pypoetry/cache/repositories/PyPI/_http/c/c/1/3/3/cc133da5701a066bc3777b2575e0daa601596f19871db4608ca98b97.lock
[filelock] Attempting to release lock 139921703037456 on /home/nanoy/.cache/pypoetry/cache/repositories/PyPI/_http/c/c/1/3/3/cc133da5701a066bc3777b2575e0daa601596f19871db4608ca98b97.lock
[filelock] Lock 139921703037456 released on /home/nanoy/.cache/pypoetry/cache/repositories/PyPI/_http/c/c/1/3/3/cc133da5701a066bc3777b2575e0daa601596f19871db4608ca98b97.lock
Source (PyPI): 17 packages found for numpy >=1.22.3,<2.0.0
   1: selecting pycryptodome (3.19.0)
   1: selecting numpy (1.26.0)
   1: Version solving took 0.335 seconds.
   1: Tried 1 solutions.

Finding the necessary packages for the current system
Source (PyPI): 1 packages found for pycryptodome >=3.16.0,<4.0.0
Source (PyPI): 1 packages found for numpy >=1.22.3,<2.0.0

Package operations: 1 install, 0 updates, 0 removals, 2 skipped

  • Installing falcon (0.9.2 906b225): Pending...
  • Installing falcon (0.9.2 906b225): Cloning...
  • Installing falcon (0.9.2 906b225): Preparing...
  • Installing falcon (0.9.2 906b225): Failed

  Stack trace:

  7  /usr/lib/python3.11/site-packages/poetry/installation/executor.py:286 in _execute_operation
      284│
      285│             try:
    → 286│                 result = self._do_execute_operation(operation)
      287│             except EnvCommandError as e:
      288│                 if e.e.returncode == -2:

  6  /usr/lib/python3.11/site-packages/poetry/installation/executor.py:386 in _do_execute_operation
      384│             return 0
      385│
    → 386│         result: int = getattr(self, f"_execute_{method}")(operation)
      387│
      388│         if result != 0:

  5  /usr/lib/python3.11/site-packages/poetry/installation/executor.py:511 in _execute_install
      509│
      510│     def _execute_install(self, operation: Install | Update) -> int:
    → 511│         status_code = self._install(operation)
      512│
      513│         self._save_url_reference(operation)

  4  /usr/lib/python3.11/site-packages/poetry/installation/executor.py:538 in _install
      536│         cleanup_archive: bool = False
      537│         if package.source_type == "git":
    → 538│             archive = self._prepare_git_archive(operation)
      539│             cleanup_archive = operation.package.develop
      540│         elif package.source_type == "file":

  3  /usr/lib/python3.11/site-packages/poetry/installation/executor.py:662 in _prepare_git_archive
      660│             )
      661│
    → 662│         archive = self._prepare_archive(operation, output_dir=output_dir)
      663│         if not package.develop:
      664│             package._source_url = original_url

  2  /usr/lib/python3.11/site-packages/poetry/installation/executor.py:615 in _prepare_archive
      613│         self._populate_hashes_dict(archive, package)
      614│
    → 615│         return self._chef.prepare(
      616│             archive, editable=package.develop, output_dir=output_dir
      617│         )

  1  /usr/lib/python3.11/site-packages/poetry/installation/chef.py:99 in prepare
       97│         if archive.is_dir():
       98│             destination = output_dir or Path(tempfile.mkdtemp(prefix="poetry-chef-"))
    →  99│             return self._prepare(archive, destination=destination, editable=editable)
      100│
      101│         return self._prepare_sdist(archive, destination=output_dir)

  TypeError

  Can't instantiate abstract class IsolatedEnv with abstract methods make_extra_environ, python_executable

  at /usr/lib/python3.11/site-packages/poetry/installation/chef.py:109 in _prepare
      105│     ) -> Path:
      106│         from subprocess import CalledProcessError
      107│
      108│         with ephemeral_environment(self._env.python) as venv:
    → 109│             env = IsolatedEnv(venv, self._pool)
      110│             builder = ProjectBuilder(
      111│                 directory,
      112│                 python_executable=env.executable,
      113│                 scripts_dir=env.scripts_dir,

  • Installing numpy (1.26.0): Pending...
  • Installing numpy (1.26.0): Skipped for the following reason: Already installed
  • Installing pycryptodome (3.19.0): Pending...
  • Installing pycryptodome (3.19.0): Skipped for the following reason: Already installed

It also has happened with other git based dependencies I cannot share (that are personal projects) but also with matplotlib (version 3.5.3).

I was using poetry for some time now, in particular for a big project I am working on and it was working very fine until recently (and to be honest I am not sure what action on my part made it switch to the non working state that I have now, potentially an update of my packages).

I don’t have any intuition on this (and it might just be a problem on my side) so any help would appreciated on this issue. In any case if it’s a configuration problem, I think we could try to improve the error message.

About this issue

  • Original URL
  • State: closed
  • Created 9 months ago
  • Reactions: 11
  • Comments: 17 (4 by maintainers)

Most upvoted comments

I found a way to rollback python-build to 0.10.0 via homebrew on my Mac M1. The command below will:

  1. remove poetry (necessary to rollback python-build)
  2. remove python-build
  3. reinstall python-build v0.10.0 from an old brew formula
  4. reinstall poetry v1.6.1 from the most recent brew formula
  5. pin each of the packages so they’re not auto-upgraded

Both poetry and python-build will need to be unpinned once the issue is resolved.

(cd /tmp &&
brew unpin poetry &&
brew remove poetry &&
brew unpin python-build &&
brew remove python-build &&
curl https://raw.githubusercontent.com/Homebrew/homebrew-core/30b71a03f7b071d71675340d5054adb2f07bd6fa/Formula/p/python-build.rb > python-build.rb &&
curl https://raw.githubusercontent.com/Homebrew/homebrew-core/30b71a03f7b071d71675340d5054adb2f07bd6fa/Formula/p/poetry.rb > poetry.rb &&
brew install python-build.rb &&
brew pin python-build &&
brew install poetry.rb &&
brew pin poetry)

Duplicate #8434, please close

@BVollmerhaus Thank you for clarifying the deeper background!

This helped me to find a solution for Arch, so in case someone is looking for a workaround while waiting for the next Poetry release, here you go:

There is a little cli tool called “downgrade” that you can find in the official Arch repos. Install it, run sudo downgrade python-build , set the version to 0.10.0 and et voilà. 👍 Hope that helps.

Homebrew’s packaging of poetry is not maintained from this repository, and not listed in the poetry docs as a way to install poetry. (Presumably because of exactly this sort of thing).

If you insist on using it anyway: please raise bugs against https://github.com/Homebrew/homebrew-core/blob/master/Formula/p/poetry.rb

I brew uninstalled poetry and re-installed poetry using curl -sSL https://install.python-poetry.org | python3 - and it cleared up this problem for me. Thanks for the tip.

Has anyone figured out a workaround for Homebrew? Sadly, the official installer is broken on macOS too: https://github.com/python-poetry/install.python-poetry.org/issues/24

poetry’s requirements do not allow build 1.0: if your poetry environment includes build 1.0 then the installation is certainly incorrect.

To provide some more context because the comment on #8434 doesn’t really explain much: Poetry 1.6(.1) specifies a dependency on build = "^0.10.0". The Arch repository (where I presume @nanoy42 installed Poetry from, but please correct me if I’m wrong) bumped their python-build package (a dependency of python-poetry) to 1.0.1 two weeks ago, which, as stated before, is not a version that Poetry’s current release is compatible with. So this seems like a distro-specific (unsupported) packaging issue to me (hence why @dimbleby called the installation “incorrect” on the linked issue).

Also worthy of note is that Poetry bumped its build dependency to ^1.0.3 on master, so I’d assume this should be resolved once the next Poetry version is released and lands in the Arch repositories.

I found a way to rollback python-build to 0.10.0 via homebrew on my Mac M1. The command below will:

  1. remove poetry (necessary to rollback python-build)
  2. remove python-build
  3. reinstall python-build v0.10.0 from an old brew formula
  4. reinstall poetry v1.6.1 from the most recent brew formula
  5. pin each of the packages so they’re not auto-upgraded

Both poetry and python-build will need to be unpinned once the issue is resolved.

(cd /tmp &&
brew unpin poetry &&
brew remove poetry &&
brew unpin python-build &&
brew remove python-build &&
curl https://raw.githubusercontent.com/Homebrew/homebrew-core/30b71a03f7b071d71675340d5054adb2f07bd6fa/Formula/p/python-build.rb > python-build.rb &&
curl https://raw.githubusercontent.com/Homebrew/homebrew-core/30b71a03f7b071d71675340d5054adb2f07bd6fa/Formula/p/poetry.rb > poetry.rb &&
brew install python-build.rb &&
brew pin python-build &&
brew install poetry.rb &&
brew pin poetry)

This works for me!!!

Homebrew’s packaging of poetry is not maintained from this repository, and not listed in the poetry docs as a way to install poetry. (Presumably because of exactly this sort of thing).

If you insist on using it anyway: please raise bugs against https://github.com/Homebrew/homebrew-core/blob/master/Formula/p/poetry.rb