英文:
Python entry_point in virtual environment not working
问题
我有一个虚拟环境,正在开发一个Python包。文件夹结构如下:
working-folder
|-setup.py
|-src
|-my_package
|-__init__.py
|-my_subpackage
|-__init__.py
|-main.py
main.py
包含一个名为 my_main
的函数,理想情况下,我希望将其作为bash命令运行。
我正在使用 setuptools
,setup
函数包含以下代码行:
setup(
...
entry_points={
"console_scripts": [
"my-command = src.my_package.my_subpackage.main:my_main",
]
},
...
)
当我运行 pip install .
时,包会正确安装到虚拟环境中。但是,在Shell上运行 my-command
时,命令不存在。
我是否漏掉了一些配置以正确生成入口点?
英文:
I have a virtual environment where I am developing a Python package. The folder tree is the following:
working-folder
|-setup.py
|-src
|-my_package
|-__init__.py
|-my_subpackage
|-__init__.py
|-main.py
main.py
contains a function my_main
that ideally, I would want to run as a bash command.
I am using setuptools
and the setup
function contains the following line of code
setup(
...
entry_point={
"console_scripts": [
"my-command = src.my_package.my_subpackage.main:my_main",
]
},
...
)
When I run pip install .
the package gets correctly installed in the virtual environment. However, when running my-command
on the shell, the command does not exist.
Am I missing some configuration to correctly generate the entry point?
答案1
得分: 0
我只是误输入了参数 entry_point
,实际上应该是 entry_points
。不幸的是,我没有收到任何输出错误。
英文:
I simply mistyped the argument entry_point
, which actually is entry_points
. Unfortunately, I was not getting any output errors.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论