Danny Dowshenko
Danny Dowshenko

Reputation: 25

python entry_point no module name __main__

I have been trying to set a new entry point for my project instead of cli, I wanted to launch main(). I have tried several variations in setup.py and can't seem to get main to import properly when it is installed with pip3

Here is the entry point code in setup.py (Note the old # code worked before with click for CLI)

entry_points={
    'console_scripts': [
        'shenko = shenko.__main__:main',
    ],
},
# This was the old entry point to run shenko as command line
#entry_points={
#    'console_scripts': [
#        'shenko=shenko.cli:main',
#    ],
#},

Here is the source code; github code, look in setup.py

Here is the last Traceback I got;

Traceback (most recent call last):
File "/home/shenko/.local/bin/shenko", line 5, in <module>
from shenko.__main__ import main
ModuleNotFoundError: No module named 'shenko.__main__'

In setup.py I have tried the following code;

'shenko = shenko.__main__:main'
'shenko = shenko:main'
'shenko = shenko.main:main'

Neither worked. Any suggestions are welcome Thank you for your time, it is most apreciated.

Upvotes: 1

Views: 2681

Answers (2)

Danny Dowshenko
Danny Dowshenko

Reputation: 25

Confirmed to be working with @phd's answer

'shenko = shenko.shenko:main'

shenko folder calls shenko.py calls main()

The issues I was having were unrelated.

Thank you for your help phd, I owe you a beer!

Upvotes: -1

phd
phd

Reputation: 94483

You don't have anything named __main__. It's neither a module __main__.py nor a function in __init__.py. Instead you have a module cli.py with a function main(). So try this:

entry_points={
    'console_scripts': [
        'shenko = shenko.cli:main',
    ],
},

Upvotes: 5

Related Questions