Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

ModuleNotFoundError even though __init.py__ exists

I have a discord bot written with python. But the catch is, it only works when deployed on heroku but doesnot run locally at all.

This is the folder structure

- feed 
  - __init__.py
  - token.py
  - main.py
-requirements.txt

When I run the command python3.9 feed/main.py, it gives the following error:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

    from feed import token
    ModuleNotFoundError: No module named 'feed'

What is the issue here? Mind you that the code runs without any errors on heroku with the same command. I am on Ubuntu 21.04.

If I change feed to .feed, I get other errors regarding absolute imports.

Please don’t redirect me to other answers, I have tried it all.

>Solution :

I don’t know how Heroku works, but to get it running locally, try changing your import to:

import token

If you want to use feed as the parent directory, you can create a setup.py file and run pip install -e . in the folder. Then doing

from feed import token

should work as part of your development environment.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading