python-poetry / poetry

Python packaging and dependency management made easy
https://python-poetry.org
MIT License
31.63k stars 2.27k forks source link

No module named 'packaging.metadata' #9034

Closed rga-coding closed 8 months ago

rga-coding commented 8 months ago

Description

poetry self update downgrades package "packaging" from 23.2 to 20 

After that all poetry command give error 
"No module named 'packaging.metadata'"

Workarounds

don't do poetry self update

Poetry Installation Method

pipx

Operating System

unix

Poetry Version

1.8.0

Poetry Configuration

cache-dir = "/home/jenkins/.cache/pypoetry"
experimental.system-git-client = false
installer.max-workers = null
installer.modern-installation = true
installer.no-binary = null
installer.parallel = true
keyring.enabled = true
repositories.cgk-thycotic.url = "https://gitlab.cegeka.com/api/v4/projects/565/packages/pypi/simple"
solver.lazy-wheel = true
virtualenvs.create = true
virtualenvs.in-project = null
virtualenvs.options.always-copy = false
virtualenvs.options.no-pip = false
virtualenvs.options.no-setuptools = false
virtualenvs.options.system-site-packages = false
virtualenvs.path = "{cache-dir}/virtualenvs"  # /home/jenkins/.cache/pypoetry/virtualenvs
virtualenvs.prefer-active-python = false
virtualenvs.prompt = "{project_name}-py{python_version}"
warnings.export = true

Python Sysconfig

No response

Example pyproject.toml

No response

Poetry Runtime Logs

Stack trace:

  16  ~/.local/share/pypoetry/venv/lib/python3.11/site-packages/cleo/application.py:327 in run
       325│ 
       326│             try:
     → 327│                 exit_code = self._run(io)
       328│             except BrokenPipeError:
       329│                 # If we are piped to another process, it may close early and send a

  15  ~/.local/share/pypoetry/venv/lib/python3.11/site-packages/poetry/console/application.py:188 in _run
       186│         self._disable_cache = io.input.has_parameter_option("--no-cache")
       187│ 
     → 188│         self._load_plugins(io)
       189│ 
       190│         exit_code: int = super()._run(io)

  14  ~/.local/share/pypoetry/venv/lib/python3.11/site-packages/poetry/console/application.py:354 in _load_plugins
       352│ 
       353│             manager = PluginManager(ApplicationPlugin.group)
     → 354│             manager.load_plugins()
       355│             manager.activate(self)
       356│ 

  13  ~/.local/share/pypoetry/venv/lib/python3.11/site-packages/poetry/plugins/plugin_manager.py:38 in load_plugins
        36│ 
        37│         for ep in plugin_entrypoints:
     →  38│             self._load_plugin_entry_point(ep)
        39│ 
        40│     @staticmethod

  12  ~/.local/share/pypoetry/venv/lib/python3.11/site-packages/poetry/plugins/plugin_manager.py:76 in _load_plugin_entry_point
        74│         logger.debug("Loading the %s plugin", ep.name)
        75│ 
     →  76│         plugin = ep.load()  # type: ignore[no-untyped-call]
        77│ 
        78│         if not issubclass(plugin, (Plugin, ApplicationPlugin)):

  11  ~/.pyenv/versions/3.11.8/lib/python3.11/importlib/metadata/__init__.py:202 in load
        200│         """
        201│         match = self.pattern.match(self.value)
     →  202│         module = import_module(match.group('module'))
        203│         attrs = filter(None, (match.group('attr') or '').split('.'))
        204│         return functools.reduce(getattr, attrs, module)

  10  ~/.pyenv/versions/3.11.8/lib/python3.11/importlib/__init__.py:126 in import_module
       124│                 break
       125│             level += 1
     → 126│     return _bootstrap._gcd_import(name[level:], package, level)
       127│ 
       128│ 

   9  <frozen importlib._bootstrap>:1204 in _gcd_import

   8  <frozen importlib._bootstrap>:1176 in _find_and_load

   7  <frozen importlib._bootstrap>:1147 in _find_and_load_unlocked

   6  <frozen importlib._bootstrap>:690 in _load_unlocked

   5  <frozen importlib._bootstrap_external>:940 in exec_module

   4  <frozen importlib._bootstrap>:241 in _call_with_frames_removed

   3  ~/.local/share/pypoetry/venv/lib/python3.11/site-packages/poetry_plugin_export/plugins.py:7 in <module>
         5│ from poetry.plugins.application_plugin import ApplicationPlugin
         6│ 
     →   7│ from poetry_plugin_export.command import ExportCommand
         8│ 
         9│ 

   2  ~/.local/share/pypoetry/venv/lib/python3.11/site-packages/poetry_plugin_export/command.py:12 in <module>
        10│ from poetry.core.packages.dependency_group import MAIN_GROUP
        11│ 
     →  12│ from poetry_plugin_export.exporter import Exporter
        13│ 
        14│ 

   1  ~/.local/share/pypoetry/venv/lib/python3.11/site-packages/poetry_plugin_export/exporter.py:11 in <module>
         9│ from cleo.io.io import IO
        10│ from poetry.core.packages.dependency_group import MAIN_GROUP
     →  11│ from poetry.repositories.http_repository import HTTPRepository
        12│ 
        13│ from poetry_plugin_export.walker import get_project_dependency_packages

  ModuleNotFoundError

  No module named 'packaging.metadata'

  at ~/.local/share/pypoetry/venv/lib/python3.11/site-packages/poetry/repositories/http_repository.py:15 in <module>
       11│ 
       12│ import requests
       13│ import requests.adapters
       14│ 
    →  15│ from packaging.metadata import parse_email
       16│ from poetry.core.constraints.version import parse_constraint
       17│ from poetry.core.packages.dependency import Dependency
       18│ from poetry.core.utils.helpers import temporary_directory
       19│ from poetry.core.version.markers import parse_marker
abn commented 8 months ago

Duplicate of #9029

rga-coding commented 8 months ago

@abn I have Uninstalled poetry like this curl -sSL https://install.python-poetry.org | python3 - --uninstall and installed it back like this curl -sSL https://install.python-poetry.org | python3 -

When I do poetry self update it still installs packaging 23.0 instead of 23.1 Like it says is the MR https://github.com/python-poetry/poetry/pull/9032/files

Am I doing something wrong?

abn commented 8 months ago

Does pipx install poetry perform any better?

abn commented 8 months ago

Am I doing something wrong?

I don't think so, this is likely because poetry when updating is locking the version to 23.0.

rga-coding commented 8 months ago

Does pipx install poetry perform any better?

I can't use pipx, the server is bein managed by someone else. I can't just install packages.

abn commented 8 months ago

You can install pipx into user site by python -m pip install --user pipx.

You can alternatively go the virtual environment poetry is installed in, typically in ~/.local/share/pypoetry/venv, and then ./bin/python -m pip install -U packaging.

The issue should go away with the next patch release.

mickeykkim commented 8 months ago

I'm still getting this error with poetry 1.8.1

clintonroy commented 8 months ago

@mickeykkim you'll need to give a lot more details for us to be able to try to reproduce your problem, how are you attempting to install poetry?

mickeykkim commented 8 months ago

After updating my poetry lockfile, my problem has been fixed. Apologies.

github-actions[bot] commented 7 months ago

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.