I am developing a Python package and I'd like to add some examples to it.
My goal is to be able to execute them by doing something like:
python3 -m package.examples.example_file_1
And the example1 will be executed
However, I can't figure out how to do so. This is my file structure:
Package
|─ examples
| |─ __init__.py
| |─ example_file_1.py
| |─ example_file_2.py
| |─ example_file_3.py
|─ __init__.py
|─ package_file_1.py
|─ package_file_2.py
|─ package_file_3.py
|─ package_file_4.py
When I run the python3 -m package.examples.example_file_1
command, I get this:
/usr/bin/python3.8: Error while finding module specification for 'package.examples.example_file_1' (ModuleNotFoundError: No module named 'package.examples')
Solution: In my setup.py file I was using setuptools.find_packages()
instead of setuptools.find_namespace_packages()
which is what is supposed to be used in python 3.3+