Peanut Peanut - 8 months ago 48
Python Question

jenv.bash: No such file or directory

I am getting the following error when trying to run my code in Python:

-bash: /usr/local/Cellar/jenv/0.2.0-201404260/libexec/../completions/jenv.bash: No such file or directory

Here is my code:

# -*- coding: utf-8 -*-

import praw
import pdb
import re
import os

# Create the Reddit instance

UA = 'MuchMeme by /u/haykam821'
r = praw.Reddit(user_agent=UA)

REDDIT_PASS = '-snip-'


# and login


subreddit = r.get_subreddit('haykam821')
comments = subreddit.get_comments(limit=100)
flat_comments = praw.helpers.flatten_tree(comments)
already_done = set()
for comment in comments:
if comment.body == 'Hello' and not in already_done:
comment.reply(' world!')

Here is the full console log of what happened when trying to run the Python code:

Last login: Sun Jul 31 02:45:28 on ttys001
cd '/Users/User/Desktop/' && '/usr/local/bin/pythonw' '/Users/User/Desktop/' && echo Exit status: $? && exit 1
-bash: /usr/local/Cellar/jenv/0.2.0-201404260/libexec/../completions/jenv.bash: No such file or directory
MacBook-Pro:~ User$ cd '/Users/User/Desktop/' && '/usr/local/bin/pythonw' '/Users/User/Desktop/' && echo Exit status: $? && exit 1
/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/praw/ DeprecationWarning: reddit intends to disable password-based authentication of API clients sometime in the near future. As a result this method will be removed in a future major version of PRAW.

For more information please see:

* Original reddit deprecation notice:

* Updated delayed deprecation notice:

Pass ``disable_warning=True`` to ``login`` to disable this warning.
warn(msg, DeprecationWarning)
Exit status: 0
Saving session...
...copying shared history...
...saving history...truncating history files...

[Process completed]


Change this line:

for comment in comments:

to this:

for comment in flat_comments:

comments is a generator, and you've already consumed all the comments it generates by flattening. Trying to iterate over it after that won't yield any results.

(You probably meant to use the flattened version anyway.)