【发布时间】:2026-02-23 19:05:03
【问题描述】:
我想把my python code打包上传到PyPI,方便大家使用。我跟着documentation打包python项目,最终上传到PyPI test website。我运行 pip install 来尝试安装它。
奇怪的是,安装后找不到包:
(base) ➜ ~ python3 -m pip install --index-url https://test.pypi.org/simple/ oomstore==0.0.4
Looking in indexes: https://test.pypi.org/simple/
Collecting oomstore==0.0.4
Downloading https://test-files.pythonhosted.org/packages/4f/a5/4e7089a1ecb36a59f7f0852a5f96a6054daf886d97132060a7efcda5f04f/oomstore-0.0.4-py3-none-any.whl (12 kB)
Installing collected packages: oomstore
Successfully installed oomstore-0.0.4
(base) ➜ ~ python3
Python 3.8.5 (default, Sep 4 2020, 02:22:02)
[Clang 10.0.0 ] :: Anaconda, Inc. on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import oomstore
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'oomstore'
>>>
我去了包的安装路径,发现里面没有python文件:
(base) ➜ ~ cd ~/miniconda3/lib/python3.8/site-packages/oomstore-0.0.4.dist-info
(base) ➜ oomstore-0.0.4.dist-info ls
INSTALLER LICENSE METADATA RECORD REQUESTED WHEEL top_level.txt
(base) ➜ oomstore-0.0.4.dist-info
我做错了吗?我的 setup.cfg 文件有问题吗?原谅我问了这么无知的问题,我是python新手……
【问题讨论】:
-
您似乎在使用 miniconda,它有自己的包管理器,名为
conda。 -
听起来有道理,但是下载一些没有python文件的元信息文件的问题似乎和conda没什么关系吧?
-
嗨 john-hen,我刚刚将其更改为
package_dir = oomstore,并运行python3 -m build报告错误,说它无法正确解析 setup.cfg,所以我不认为那就是问题所在。感谢您的回答! -
不,该条目在技术上是正确的:
package_dir想要从名称到路径的映射,其中空字符串是根包概念的有效名称(意味着*模块不是在包裹)。 ini 格式掩盖了这里左边的值是一个空字符串,因为没有引号或其他分隔符。
标签: python python-3.x setuptools setup.py miniconda