Received 'can't find '__main__' module in '' with python package

后端 未结 3 1534
半阙折子戏
半阙折子戏 2020-12-10 02:58

I\'m trying to release my first Python package in the wild and I was successful in setting it up on PyPi and able to do a pip install. When I try to run the pa

3条回答
  •  借酒劲吻你
    2020-12-10 03:07

    I recently got the same issue and finaly find the solution by my self. So as the error said, I added a file __main__.py at the same path that my __init__.py.

    Inside __main__.py I added the following code :

     from mypackage.mymodule import main 
          main() 
    

    main() was the main function of my code. And it's works now.

    here my directory:

    package 
    |__dirpackage
       |_mypackage.py
       |_ __init__.py
       |_ __main__.py
    |_setup.py`
    

提交回复
热议问题