Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ImportError: No module named 'praw' #4

Open
thatirishguyyy opened this issue Feb 20, 2021 · 1 comment
Open

ImportError: No module named 'praw' #4

thatirishguyyy opened this issue Feb 20, 2021 · 1 comment

Comments

@thatirishguyyy
Copy link

thatirishguyyy commented Feb 20, 2021

Hi,

I doubt this is an issue with your code but perhaps you could help since I can't seem to find anything on Google.

When testing the code in IDLE it keeps coming back with this:

Traceback (most recent call last):
File "C:\Users\thati\OneDrive\Desktop\comment.py", line 1, in
import praw
ImportError: No module named 'praw'

But I have praw installed. I've checked using help('modules') and it lists praw. I even installed using pip3. ot sure what is going on. This is a fresh install on a new PC and I haven't used python since college but it can't be that hard to install a module with the new python.

I also had to change all the "wording" to ("wording") to fix thaat syntax error and I'm not sure if that was a mistake. Again,. haven't used Python since college, which is about 9 years now.

So, minus the module issue I've made the appropriate changes, and changes I think might work (the quotes). I've changed my personal info to PERSONAL where I believe I'm supposed to add my info. Here is what I have so far:

import praw
import config
import time
import os

def bot_login():
print ("Logging in")
r = praw.Reddit(username = config.PERSONAL,
password = config.PERSONAL,
client_id = config.PERSONAL,
client_secret = config.PERSONAL,
user_agent = "The Reddit Commenter v1.0")
print ("Logged in!")

return r

def run_bot(r, comments_replied_to):
print ("Searching last 1,000 comments")

for comment in r.subreddit('test').comments(limit=1000):
	if "You" in comment.body and comment.id not in comments_replied_to and comment.author != r.user.me():
		print ("String with \"You\" found in comment ") + comment.id
		comment.reply("Congrats, you are smarter than PERSONAL")
		print ("Replied to comment ") + comment.id

		comments_replied_to.append(comment.id)

		with open ("comments_replied_to.txt", "a") as f:
			f.write(comment.id + "\n")

print ("Search Completed.")

print (comments_replied_to)

print ("Sleeping for 10 seconds...")
#Sleep for 10 seconds...		
time.sleep(10)

def get_saved_comments():
if not os.path.isfile("comments_replied_to.txt"):
comments_replied_to = []
else:
with open("comments_replied_to.txt", "r") as f:
comments_replied_to = f.read()
comments_replied_to = comments_replied_to.split("\n")
comments_replied_to = filter(None, comments_replied_to)

return comments_replied_to

r = bot_login()
comments_replied_to = get_saved_comments()
print (comments_replied_to)

while True:
run_bot(r, comments_replied_to)

@thatirishguyyy
Copy link
Author

I also have no idea how to get my comment to look better. Some of it showed up as code, the rest as text.

Repository owner deleted a comment from notboeing747 Jan 20, 2022
Repository owner deleted a comment from notboeing747 Jan 20, 2022
Repository owner deleted a comment from notboeing747 Jan 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant