[Answered ]-How to fix "ImportError: No module named …" error

2👍

The problem turned out to be that I had a non-standard project directory structure. I was missing an __init__.py file in in my ‘django_trial_on_mac’ directory. As soon as I created an empty __init__.pyfile there, the app ran normally.

__init__.py files tell Django that the directory should be treated as a package and since this file did not exist in the ‘django_trial_on_mac’ directory, it could not import the module ‘django_trial_on_mac’.

0👍

Hard to answer without more info, but it looks like something is wrong with PYTHONPATH env variable on your Heroku:

  • it does not include your project directory, or
  • you might have a non-standard project directory structure, or
  • the problem might be something as simple as uploading the project with its parent directory, and not only the project directory…
👤frnhr

Leave a comment