打包 python 个项目失败

packaging python projects failed

我要打包my python code and upload it to PyPI so that people can use it easily. I followed the documentation for packaging python projects and eventually uploaded it to the PyPI test website。我 运行 pip install 尝试安装它。

St运行太好了,安装后找不到包:

(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 文件有问题吗?请原谅我问这样一个无知运行t 问题,我是python...

的新手

问题是您的 package_dir 选项告诉安装工具在 oomstore 目录中查找模块和包,但您的 oomstore 包就在 [= 旁边22=]。您应该删除该选项。

您还可以将 oomstore 移动到 src 目录并配置 package_dir =\n = src;有关将模块放入 src 目录的原因,请参阅这篇文章:https://hynek.me/articles/testing-packaging/