'setup.py runs but I get a "ModuleNotFoundError" when trying to import my package

I have a setup.py file. I run it using pip install -e .. The logging suggest my package is successfully installed. But when I run python -c "from mypackage import test_script" I get the error ModuleNotFoundError: No module named 'mypackage'. My setup.py file looks like:

from setuptools import find_packages, setup

setup(
   name="mypackage",
   packages=find_package(include=["src", "src.*"]),
   version="0.0.1",
   description="my pakage",
   author="me",
)

My package folder looks like:

src
   mypackage
      __init__.py
      test_script.py

python -c "from src.mypackage import test_script" does work, but I don't want my package name to be preceeded with "src". Any ideas what is going wrong?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source