Heroku: ModuleNotFoundError: No module named 'config'

You should use environment variables for this, so:

  1. this creates the env variable in your heroku application
    heroku config:set MAPBOX_TOKEN="pk.fooooooooooooo"
  2. this loads the env variable in your code
import os
os.getenv('MAPBOX_TOKEN')
  1. Remove the config.py from your .gitignore

You can also manage environment variables in heroku UI in your app settings

1 Like