我正在try 创建一个Python pip包.这也很有效.我可以成功地上传和下载这个包,并在Python代码中使用它.我不能通过命令行使用Python包.在另一篇StackOverflow帖子中,我找到了一个教程的链接.我试着跟着它走.显然我犯了个错误.你们能帮帮我吗?
我创建了一个简单的Python包.这里只代表了一个例子.在这里你可以看到文件夹的 struct
Riffecs
| .gitignore
| .pylintrc
| LICENSE
| README.md
| requirements.txt
| setup.py
|
|
\---riffecs
__init__.py
__main__.py
以下是显示的基本文件.
main.py
from . import hello_world
if __name__ == '__main__':
hello_world()
还有init.py
def hello_world():
print("Hello world")
在以下内容中,您可以看到"setup.py".我认为我已遵照指示行事.但很明显我在某个地方犯了个错误.你能帮我纠正这个错误吗.
import io
import os
import setuptools
def read_description():
url = "README.md"
""" Read and Return the description """
return io.open(os.path.join(os.path.dirname(__file__), url), encoding="utf-8").read()
def def_requirements():
""" Check PIP Requirements """
with open('requirements.txt', encoding='utf-8') as file_content:
pip_lines = file_content.read().splitlines()
return pip_lines
setuptools.setup(
name="riffecs",
version='0.0.3',
description='test',
entry_points={'console_scripts': ['hello-world=riffecs:hello_world',]},
long_description=read_description(),
long_description_content_type="text/markdown",
license="MIT",
keywords="test - riffecs",
url="https://github.com/Riffecs/riffecs",
packages=["riffecs"],
install_requires=def_requirements(),
python_requires=">=3.6",
classifiers=[
"Development Status :: 4 - Beta",
"Intended Audience :: Developers",
"Intended Audience :: Science/Research",
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
"Programming Language :: Python",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
],
)