Python入口点在虚拟环境中无法工作。

huangapple go评论60阅读模式
英文:

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命令运行。

我正在使用 setuptoolssetup 函数包含以下代码行:

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.

huangapple
  • 本文由 发表于 2023年2月6日 22:04:40
  • 转载请务必保留本文链接:https://go.coder-hub.com/75362342.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定