我将一个包推送到pypip,然后成功地安装了它。
因为我在anaconda上,所以我可以conda list
并确认我的包安装在基本环境中。在
接下来我要使用它:
from epicprint import Print
但这会抛出一个ModuleNotFoundError:没有名为“epicprint”的模块
我想我的包结构有一些错误。在我的测试.py奇怪的文件。请参阅以下文件包回购:
from Print import Print
import setuptools
with open("README.md", "r") as fh:
long_description = fh.read()
setuptools.setup(
name='epicprint',
version='0.1',
author="abc",
author_email="abc@abc.com",
description="Custom print with superpowers",
url="https://github.com/ajthinking/print",
packages=setuptools.find_packages(),
classifiers=[
"Programming Language :: Python :: 3",
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
],
)
from Print import Print
print = Print()
print.info("Welcome").group()
print.success("Now we can:", ["Indent stuff", "Use colors", "Attach semantic to the print statements"])
print.warning("Nothing more to say")
print.reset().fail("Ending with a fail message. Bye.")
除了一个.whl和一个文件外,所有文件都在repo的根目录下。焦油gz在运行安装脚本后在dist文件夹以及build和egg info文件夹中找到。在
├── LICENSE
├── Print.py
├── README.md
├── __init__.py
├── __pycache__
│ └── Print.cpython-37.pyc
├── build
│ └── bdist.macosx-10.7-x86_64
├── dist
│ ├── epicprint-0.1-py3-none-any.whl
│ └── epicprint-0.1.tar.gz
├── epicprint.egg-info
│ ├── PKG-INFO
│ ├── SOURCES.txt
│ ├── dependency_links.txt
│ └── top_level.txt
├── setup.py
└── test.py
我哪里出错了?在
您没有任何包目录(带有
__init__.py
的子目录),因此setuptools.find_packages()
返回一个空列表,因此您的发行版不包含也不安装任何python模块或包。在将
Print.py
安装为独立模块:或者将}包,发行版将捕获它。在
Print.py
和__init__.py
移到子目录epicprint/
,然后setuptools.find_packages()
返回{在后一种情况下,
^{pr2}$test.py
必须进行调整:您是否希望
test.py
加入epicprint/
软件包由您决定。在相关问题 更多 >
编程相关推荐