tommeagher / heroku_ebooks

An archive of a script to generate Markov chains and to post to an _ebooks account on Twitter using Heroku. No longer actively supported.
264 stars 163 forks source link

ModuleNotFoundError: No module named 'local_settings' #54

Closed gamerswift13 closed 6 years ago

gamerswift13 commented 6 years ago

I have set up this bot successfully once, in February this year using Twitter but I am now running into problems using it for Mastodon, but I don't think the problem is with either service.

I have followed all the steps described multiple times but I keep getting the following error when trying the first heroku run worker command:

Running worker on gentle-ridge-53367... up, run.1762 (Free)
Traceback (most recent call last):
  File "ebooks.py", line 17, in <module>
    from local_settings import *
ModuleNotFoundError: No module named 'local_settings'

I've definitely got the correct file name etc and I've tried changing the runtime.txt several different versions of Python to see if it makes any difference but it doesn't? Have attached my local_settings.py file in case there's something obvious that I've somehow missed. For the record I am very new to coding so I apologise if I'm just wasting your time with a mistake I've made.

local_settings (copy).txt

tommeagher commented 6 years ago

@gamerswift13, is your file in your repo named "local_settings (copy).txt"? If so, that's probably the problem. It's looking specifically for a file named "local_settings.py" If you rename it and commit it and push it back to heroku, it should fix that issue. Let me know if that helps.

gamerswift13 commented 6 years ago

No, I had to copy the file because github wouldn’t let me upload a .py file and I just forgot to remove the (copy) part from the filename. someone I spoke to on Mastodon pointed out that local_settings.py is named in gitignore but I haven’t had a chance to verify that myself yet.

EDIT: I've double-checked my older bot made using your code from February and the .gitignore there doesn't include local_settings.py, but removing that line from .gitignore in my current bot doesn't make any difference - I'm still seeing ModuleNotFoundError.

TimLChan commented 6 years ago

@gamerswift13 In the heroku app, can you do the following:

  1. Click on the "more" drop down
  2. Click on "Run Console"
  3. Type in bash
  4. When it loads, type "ls" without quotes

Do you see local_settings.py?

gamerswift13 commented 6 years ago

Oops! No it wasn't there! But after removing the filename from .gitignore and then adding local_settings.py manually and pushing it, it works fine. Sorry for bothering you with something so basic but thank you so much for your help! I definitely don't think I would have got there on my own.