Poetry: No module named 'importlib_metadata' with python3.8

Created on 20 Oct 2019  ·  7Comments  ·  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).

Issue

When I run poetry run with python3.8 I get this error:

0.25s$ poetry run flake8 .
Traceback (most recent call last):
  File "/home/travis/virtualenv/python3.8.0/bin/poetry", line 5, in <module>
    from poetry.console import main
  File "/home/travis/virtualenv/python3.8.0/lib/python3.8/site-packages/poetry/console/__init__.py", line 1, in <module>
    from .application import Application
  File "/home/travis/virtualenv/python3.8.0/lib/python3.8/site-packages/poetry/console/application.py", line 7, in <module>
    from .commands import AboutCommand
  File "/home/travis/virtualenv/python3.8.0/lib/python3.8/site-packages/poetry/console/commands/__init__.py", line 4, in <module>
    from .check import CheckCommand
  File "/home/travis/virtualenv/python3.8.0/lib/python3.8/site-packages/poetry/console/commands/check.py", line 1, in <module>
    from poetry.factory import Factory
  File "/home/travis/virtualenv/python3.8.0/lib/python3.8/site-packages/poetry/factory.py", line 15, in <module>
    from .json import validate_object
  File "/home/travis/virtualenv/python3.8.0/lib/python3.8/site-packages/poetry/json/__init__.py", line 4, in <module>
    import jsonschema
  File "/home/travis/virtualenv/python3.8.0/lib/python3.8/site-packages/jsonschema/__init__.py", line 31, in <module>
    import importlib_metadata
ModuleNotFoundError: No module named 'importlib_metadata'

Link to the CI: https://travis-ci.org/sobolevn/flake8-positional-only/jobs/600167655#L368

I have tried to:

  1. Run poetry with -vvv - no change in the result
  2. Install importlib_metadata manually inside the venv and the root system
  3. Install poetry via pip and via curl (curl has different issue, see #1377)

No luck.

Bug

Most helpful comment

This is probably caused by a typo in this line:
https://github.com/sdispater/poetry/blob/481d81d/pyproject.toml#L58

It should be < 3.8, not <= 3.8.

All 7 comments

Hello,

I'm not sure that this is poetry problem. importlib_metadata is buildin_module since python3.8 but renamed to importlib.metadata. Which version of jsonschema is running in the (root?) environment where poetry is installed?

Until now I'm not able to reproduce the error.

fin swimmer

Also experimenting this issue on Python 3.8.0 / TravisCI: https://travis-ci.com/florimondmanca/ddtrace-asgi/jobs/252426060

I managed to fix the issue by installing using the latest Poetry version via get-poetry.py:

before_install:
  - curl -sSL https://raw.githubusercontent.com/sdispater/poetry/master/get-poetry.py > get-poetry.py
  - python get-poetry.py -y --version 1.0.0b3
  - source ~/.poetry/env

install:
  - poetry install -v

Successful build here: https://travis-ci.com/florimondmanca/ddtrace-asgi/jobs/252427083

Not sure what the origin of the issue is, nor why it is only affecting 3.8 — perhaps a clash between importlib_metadata / importlib.metadata / Poetry's own vendorized dependencies?

i'm also experiencing the issue with installations on Travis but not locally.

Are you testing on multiple versions of Python? Try removing poetry.lock from your repo.

Seems like poetry removes its own dependency each time something adds or removes (or even install).

➜ poetry install
Installing dependencies from lock file

Package operations: 0 installs, 0 updates, 2 removals

  - Removing importlib-metadata (0.23)
  - Removing zipp (0.6.0)
  - Installing redis-index (0.1.0)

➜ poetry add statsd
[ModuleNotFoundError]
No module named 'importlib_metadata'

➜ pip install importlib_metadata
...

➜ poetry add statsd
Using version ^3.3 for statsd

Updating dependencies
Resolving dependencies... (0.4s)

Writing lock file


Package operations: 1 install, 0 updates, 2 removals

  - Installing statsd (3.3.0)
  - Removing importlib-metadata (0.23)
  - Removing zipp (0.6.0)

I have the same problem on Python 3.8

This is probably caused by a typo in this line:
https://github.com/sdispater/poetry/blob/481d81d/pyproject.toml#L58

It should be < 3.8, not <= 3.8.

@sdispater can this be released as 0.12.x? Because currently it is impossible to use poetry with python3.8

Was this page helpful?
0 / 5 - 0 ratings