Python can't find local files/modules

I’m setting up a Flask application on Digitalocean and have Python 3.7 installed and the latest version of Flask. When running the app inside a virtualenv and trying to run the application using python3.7 I get the following error message:

Traceback (most recent call last):
    File "", line 11, in <module>
        from config import *
ModuleNotFoundError: No module named 'config'

What puzzles me is that is located in the same folder as, and not in a subfolder. I have duplicated the setup on my local machine, also running Python 3.7 and inside a virtualenv, and the importing (and the app) works flawlessly.

I’ve tried importing “” instead of just “config” but didn’t make a difference. I also tried specifying exactly what it should import (instead of using ‘*’) but that didn’t make a difference either.

Your thoughts on why it can’t find config?

Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

If your file and file on the same path, move file outside of the path and place the same in root.

for example if both are in “APP” directory, move the and place it inside the root director of “APP” directory


What I could suggest here is trying to install the module first:

pip3 install config

Then run it again and see how it goes.

Hope that this helps! Regards, Bobby