English 中文(简体)
没有称为进口校准的模块。 甚至在安装后元数据
原标题:No module named importlib.metadata even after installing it

File "/home/username/.local/lib/python3.7/site-packages/kodi_cli.py", line 3, in import importlib.metadata ModuleNotFoundError: No module named importlib.metadata

pip3 install kodi-cli --user

Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple Requirement already satisfied: kodi-cli in /home/username/.local/lib/python3.7/site-packages (0.1.9) Requirement already satisfied: requests<3.0.0,>=2.28.0 in /home/username/.local/lib/python3.7/site-packages (from kodi-cli) (2.28.1) Requirement already satisfied: urllib3<1.27,>=1.21.1 in /usr/lib/python3/dist-packages (from requests<3.0.0,>=2.28.0->kodi-cli) (1.24.1) Requirement already satisfied: charset-normalizer<3,>=2 in /home/username/.local/lib/python3.7/site-packages (from requests<3.0.0,>=2.28.0->kodi-cli) (2.0.4) Requirement already satisfied: certifi>=2017.4.17 in /usr/lib/python3/dist-packages (from requests<3.0.0,>=2.28.0->kodi-cli) (2018.8.24) Requirement already satisfied: idna<4,>=2.5 in /usr/lib/python3/dist-packages (from requests<3.0.0,>=2.28.0->kodi-cli) (2.6)

kodi-cli -H host -P 8080 -u username -p password -C

我把这一错误摆在首位。

pip3 install importlib-metadata --user

Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple Requirement already satisfied: importlib-metadata in /home/username/.local/lib/python3.7/site-packages (5.0.0) Requirement already satisfied: zipp>=0.5 in /home/username/.local/lib/python3.7/site-packages (from importlib-metadata) (3.10.0) Requirement already satisfied: typing-extensions>=3.6.4; python_version < "3.8" in /home/username/.local/lib/python3.7/site-packages (from importlib-metadata) (3.10.0.0)

仍有错误。

python3 --version

3.7.3

cat /etc/os-release

PRETTY_NAME="Raspbian GNU/Linux 10 (buster)" NAME="Raspbian GNU/Linux" VERSION_ID="10" VERSION="10 (buster)" VERSION_CODENAME=buster ID=raspbian ID_LIKE=debian HOME_URL="http://www.raspbian.org/" SUPPORT_URL="http://www.raspbian.org/RaspbianForums" BUG_REPORT_URL="http://www.raspbian.org/RaspbianBugs"

我在此祝贺我。 希望得到任何帮助。

我怀疑,在“Kkodi_cli.py”方案中,它可能必须这样做。

import importlib.metadata
import json
import logging
import os
import pathlib
import sys
import textwrap

import version as ver_info
from kodi_interface import KodiObj

__version__ = importlib.metadata.version("kodi-cli")
最佳回答

我刚刚听从评论中所说的话,我为我工作。 很细微。

python 3.8 and up use importlib. 1. 元数据,低于3.8, 用于进口平衡-metadata/em。

在我的案件中:

from importlib_metadata import packages_distributions
packages_distributions() # I wanted to see all distribution names and their import names
问题回答

而不是

import importlib.metadata

书写

from importlib_metadata import metadata

如果进口校准-元数据模块没有安装,则首先通过安装设备安装。

pip install importlib-metadata

详细情况:





相关问题
Get webpage contents with Python?

I m using Python 3.1, if that helps. Anyways, I m trying to get the contents of this webpage. I Googled for a little bit and tried different things, but they didn t work. I m guessing that this ...

What is internal representation of string in Python 3.x

In Python 3.x, a string consists of items of Unicode ordinal. (See the quotation from the language reference below.) What is the internal representation of Unicode string? Is it UTF-16? The items ...

What does Python s builtin __build_class__ do?

In Python 3.1, there is a new builtin function I don t know in the builtins module: __build_class__(...) __build_class__(func, name, *bases, metaclass=None, **kwds) -> class Internal ...

what functional tools remain in Python 3k?

I have have read several entries regarding dropping several functional functions from future python, including map and reduce. What is the official policy regarding functional extensions? is lambda ...

Building executables for Python 3 and PyQt

I built a rather simple application in Python 3.1 using PyQt4. Being done, I want the application to be distributed to computers without either of those installed. I almost exclusively care about ...