Python Language Creating Python packages Making package executable


Example

If your package isn't only a library, but has a piece of code that can be used either as a showcase or a standalone application when your package is installed, put that piece of code into __main__.py file.

Put the __main__.py in the package_name folder. This way you will be able to run it directly from console:

python -m package_name

If there's no __main__.py file available, the package won't run with this command and this error will be printed:

python: No module named package_name.__main__; 'package_name' is a package and cannot be directly executed.