Python安装工具导入另一个Pip包时出现ModuleNotFoundError

问题描述 投票:0回答:1

我正在尝试使用 setuptools 构建一个wheel/sdist,当我的一个脚本导入时,它给我一个错误

bs4
(beautifulsoup4)。 这是运行后显示的内容
python3 -m build
:

* Creating venv isolated environment...
* Installing packages in isolated environment... (setuptools >= 40.8.0)
* Getting build dependencies for sdist...

ModuleNotFoundError: No module named 'bs4'

ERROR Backend subprocess exited when trying to invoke get_requires_for_build_sdist

这就是它检测到的错误:

from bs4 import BeautifulSoup

这是我的设置.py:

import setuptools
import mypackage

def readme():
    with open("README.md", 'r') as f:
        return f.read()

setuptools.setup(
    name="mypackage",
    version=mypackage.__version__,
    author=mypackage.__author__,
    maintainer=mypackage.__author__,
    description=mypackage.__description__,
    long_description=readme(),
    long_description_content_type="text/markdown",
    license=mypackage.__license__,
    python_requires=">=3.10",
    install_requires=[
        "beautifulsoup4",
    ],
)

这很有压力:/

版本
安装工具版本:69.0.3
Python版本:3.11.8

python pip subprocess setuptools python-wheel
1个回答
0
投票

要解决此错误,您需要使用 pip 安装 beautifulsoup4 库,如下所示:

pip install beautifulsoup4

对于 pip3:

pip3 install beautifulsoup4

安装模块后,您应该能够运行导入 bs4 的代码而不会收到此错误。

© www.soinside.com 2019 - 2024. All rights reserved.