pip安装轮后导入模块

发布于 2025-01-17 19:57:20 字数 1758 浏览 0 评论 0原文

我有一个自定义的构建模块,我们将其称为 abcpip install /local_path/abc-0.1-py3-none-any.whl。安装正确,

>>pip install dist/abc-0.1-py3-none-any.whl
Processing ./dist/abc-0.1-py3-none-any.whl
Successfully installed abc-0.1

但无法导入模块。 我运行 ppip freeze list 并发现列表中的模块名称是 abc @ file:///local_path/abc-0.1-py3-none-any.whl 后。
我的问题是如何导入模块?谢谢

.
├── requirements.txt
├── setup.py
├── src
│   ├── bin
│   │   ├── __init__.py
│   │   ├── xyz1.py
│   │   ├── xyz2.py
│   │   └── xyz3.py

,这是我的 setup.py

with open("requirements.txt") as f:
    install_requires = f.read()

setup(
    name="abc",
    version="0.1",
    author="galaxyan",
    author_email="[email protected]",
    description="test whell framework",
    packages=find_packages(include=["src"]),
    zip_safe=False,
    install_requires=install_requires,
)

############ 更新 ############
即使更改 setup.py 也不起作用

with open("requirements.txt") as f:
    install_requires = f.read()

setup(
    name="abc",
    version="0.1",
    author="galaxyan",
    author_email="[email protected]",
    description="test whell framework",
    packages=find_packages(where="src"),
    package_dir={"": "src"},
    zip_safe=False,
    install_requires=install_requires,
)

I have a customized built module, lets call it abc, and pip install /local_path/abc-0.1-py3-none-any.whl. Installation is correct,

>>pip install dist/abc-0.1-py3-none-any.whl
Processing ./dist/abc-0.1-py3-none-any.whl
Successfully installed abc-0.1

but I could not import the module.
After I ran ppip freeze list and found out the name of module in list is abc @ file:///local_path/abc-0.1-py3-none-any.whl.
my question is how could import the module? Thank you

.
├── requirements.txt
├── setup.py
├── src
│   ├── bin
│   │   ├── __init__.py
│   │   ├── xyz1.py
│   │   ├── xyz2.py
│   │   └── xyz3.py

here is my setup.py

with open("requirements.txt") as f:
    install_requires = f.read()

setup(
    name="abc",
    version="0.1",
    author="galaxyan",
    author_email="[email protected]",
    description="test whell framework",
    packages=find_packages(include=["src"]),
    zip_safe=False,
    install_requires=install_requires,
)

############ update ############
it does not work even change setup.py

with open("requirements.txt") as f:
    install_requires = f.read()

setup(
    name="abc",
    version="0.1",
    author="galaxyan",
    author_email="[email protected]",
    description="test whell framework",
    packages=find_packages(where="src"),
    package_dir={"": "src"},
    zip_safe=False,
    install_requires=install_requires,
)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

空心↖ 2025-01-24 19:57:20

setup.py是错误的,这意味着您正在构建内部没有包装的车轮。

而不是

setup(
    ...
    packages=find_packages(include=["src"]),
    ...
)

尝试以下操作:

setup(
    ...
    packages=find_packages(where="src"),
    package_dir={"": "src"},
    ...
)

请参阅 testing&包装有关更多信息。

The setup.py is wrong, which means you're building a wheel with no packages actually inside.

Instead of

setup(
    ...
    packages=find_packages(include=["src"]),
    ...
)

Try this:

setup(
    ...
    packages=find_packages(where="src"),
    package_dir={"": "src"},
    ...
)

See Testing & Packaging for more info.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文