Using old python version 3.8.6. I created virtual environment in /var/virtualenvs/myvenv and installed mypkg.bouncer.client but when we import that, it gives below error. Traceback (most recent call last): File "/var/virtualenvs/myvenv/lib/python3.8/site-packages/mypkg/contrib/myapp/wsgi.py", line 22, in <module> application = get_wsgi_application() File "/var/virtualenvs/myvenv/lib/python3.8/site-packages/django/core/wsgi.py", line 13, in get_wsgi_application return WSGIHandler() File "/var/virtualenvs/myvenv/lib/python3.8/site-packages/django/core/handlers/wsgi.py", line 127, in __init__ self.load_middleware() File "/var/virtualenvs/myvenv/lib/python3.8/site-packages/django/core/handlers/base.py", line 40, in load_middleware middleware = import_string(middleware_path) File "/var/virtualenvs/myvenv/lib/python3.8/site-packages/django/utils/module_loading.py", line 17, in import_string module = import_module(module_path) File "/lib/python3.8/importlib/__init__.py", line 127, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "/var/virtualenvs/myvenv/lib/python3.8/site-packages/mypkg/contrib/myapi/authentication/middleware.py", line 14, in <module> from mypkg.bouncer.client import endpoints File "/var/virtualenvs/myvenv/lib/python3.8/site-packages/mypkg/bouncer/client/__init__.py", line 16, in <module> __version__ = pkg_resources.get_distribution("mypkg.bouncer.client").version File "/var/virtualenvs/myvenv/lib/python3.8/site-packages/pkg_resources/__init__.py", line 534, in get_distribution dist = get_provider(dist) File "/var/virtualenvs/myvenv/lib/python3.8/site-packages/pkg_resources/__init__.py", line 417, in get_provider return working_set.find(moduleOrReq) or require(str(moduleOrReq))[0] File "/var/virtualenvs/myvenv/lib/python3.8/site-packages/pkg_resources/__init__.py", line 1070, in require needed = self.resolve(parse_requirements(requirements)) File "/var/virtualenvs/myvenv/lib/python3.8/site-packages/pkg_resources/__init__.py", line 897, in resolve dist = self._resolve_dist( File "/var/virtualenvs/myvenv/lib/python3.8/site-packages/pkg_resources/__init__.py", line 938, in _resolve_dist raise DistributionNotFound(req, requirers) pkg_resources.DistributionNotFound: The 'mypkg.bouncer.client' distribution was not found and is required by the application When we check the pip freeze to make sure that package is installed, it gives the package name. [user@test-01 ~]$ /var/virtualenvs/myvenv/bin/python -m pip freeze | grep mypkg.bouncer.client mypkg.bouncer.client==0.X.Y I also check the files exists in the lib/site-packages [myuser@test-01 ~]$ ls -al /var/virtualenvs/myvenv/lib/python3.8/site-packages/mypkg/bouncer/client/ total 32 drwxrwxr-x 3 myuser users 136 Apr 29 11:28 . drwxrwxr-x 5 myuser users 104 Apr 29 11:28 .. -rw-rwxr-- 1 myuser users 454 Apr 29 11:28 endpoints.py -rw-rwxr-- 1 myuser users 1301 Apr 29 11:28 errors.py -rw-rwxr-- 1 myuser users 481 Apr 29 11:28 __init__.py drwxrwxr-x 2 myuser users 189 Apr 29 11:28 __pycache__ not sure why its giving error? EDIT I found that, its due to working_set.by_key is not updated with mypkg.bouncer.client. sudo /var/virtualenvs/myenv/bin/python -c 'import pkg_resources;print(pkg_resources.working_set.by_key)' this dont have entry for mypkg. How this by_key is updated ? Continue reading...