alexlaverty / python-reddit-youtube-bot

Automated Reddit Youtube Video Bot
https://www.youtube.com/channel/UCzIwW92D_rM5_yvWBsquSbw
78 stars 17 forks source link

Issue When I try to run app.py #43

Closed 13xJ closed 1 year ago

13xJ commented 1 year ago

Hi, when i try to run app.py i get this error message

File Not Found Traceback (most recent call last): File "d:\ttsvibelounge-1.0.0\app.py", line 5, in import video File "d:\ttsvibelounge-1.0.0\video.py", line 14, in import keywords File "d:\ttsvibelounge-1.0.0\keywords.py", line 1, in from multi_rake import Rake ModuleNotFoundError: No module named 'multi_rake'

I don't understand what i'm doing wrong I have rake installed as Well. Thanks For Helping.

alexlaverty commented 1 year ago

Do you have the latest version of the code? Can you do a git pull to pull latest changes, multi_rake was removed a while ago

13xJ commented 1 year ago

Hi, I have solved that issue but now im getting this. File "d:\ttsvibelounge-main\app.py", line 5, in import reddit.reddit as reddit File "d:\ttsvibelounge-main\reddit\reddit.py", line 2, in import config.settings as settings ModuleNotFoundError: No module named 'config.settings' Sorry if this is a simple fix but I'm new python. Thanks

alexlaverty commented 1 year ago

Make sure you change directory into the folder when you run the script like :

cd d:\ttsvibelounge-main
python app.py

Because script needs to be able to access from that folder the other files it needs

can you share a screenshot of your folder that contains app.py, make sure you've downloaded all the files and folders that are in the repo.

Also make sure you pip install all the dependencies :

pip install -r requirements.txt
python app.py

Can you share your python version as well, i am currently running this version of python :

python --version
Python 3.10.5
13xJ commented 1 year ago

Im currently running Python 3.10.7 https://prnt.sc/Mg0TKpX_Q_WK. Ive tried everything you've told me to do but im stilling getting a error

alexlaverty commented 1 year ago

Can you upload a screenshot of your terminal where you are running the command to run the script, you should be able to paste the image directly into the comment,

Did you copy the example config in the settings folder?

cp config-example.py config.py
13xJ commented 1 year ago

I mainly run Visual Studio Code but if the file doesn't work I run it in the cmd terminal. Whenever I try to run cp it doesn't work for me it comes up as cp is not recognized. So Instead I changed the auth example to auth and populated it with my information. image

alexlaverty commented 1 year ago

in that terminal can you run :

dir config 

So I can see the contents of the folder, really that code is just trying to import the file :

config\settings.py

and for some reason can't find it

13xJ commented 1 year ago

This is the cmd output image

alexlaverty commented 1 year ago

Should look more like below, can you rename configsettings.py to settings.py and try again :

c:\src\ttsvibelounge>dir config

Directory of c:\src\ttsvibelounge\config

11/08/2022  10:43 PM    <DIR>          .
11/08/2022  10:43 PM    <DIR>          ..
11/08/2022  10:43 PM               567 auth-env.py
10/29/2022  09:16 AM               224 auth-example.py
11/08/2022  08:41 PM               383 auth.py
11/09/2022  11:29 PM             3,720 settings.py
11/09/2022  11:29 PM    <DIR>          __pycache__
               4 File(s)          4,894 bytes
               3 Dir(s)  891,473,489,920 bytes free
13xJ commented 1 year ago

I don't get that error anymore but I get this now.

ID, SCORE, NUM_COMMENTS, LEN_SELFTEXT, SUBREDDIT, TITLE
Traceback (most recent call last):
  File "C:\Users\AppData\Local\Programs\Python\Python310\lib\site-packages\prawcore\requestor.py", line 58, in request
    return self._http.request(
  File "C:\Users\AppData\Local\Programs\Python\Python310\lib\site-packages\requests\sessions.py", line 573, in request
    prep = self.prepare_request(req)
  File "C:\Users\AppData\Local\Programs\Python\Python310\lib\site-packages\requests\sessions.py", line 484, in prepare_request
    p.prepare(
  File "C:\Users\AppData\Local\Programs\Python\Python310\lib\site-packages\requests\models.py", line 369, in prepare
    self.prepare_headers(headers)
  File "C:\Users\AppData\Local\Programs\Python\Python310\lib\site-packages\requests\models.py", line 491, in prepare_headers
    check_header_validity(header)
  File "C:\Users\AppData\Local\Programs\Python\Python310\lib\site-packages\requests\utils.py", line 1043, in check_header_validity
    _validate_header_part(value, "value", HEADER_VALIDATORS[type(value)][1])
  File "C:\Users\AppData\Local\Programs\Python\Python310\lib\site-packages\requests\utils.py", line 1048, in _validate_header_part
    raise InvalidHeader(
requests.exceptions.InvalidHeader: Invalid leading whitespace, reserved character(s), or returncharacter(s) in header value: ' PRAW/7.6.0 prawcore/2.3.0'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "c:\Users\Downloads\ttsvibelounge-main\app.py", line 285, in <module>
    submissions = reddit.posts()
  File "c:\Users\Downloads\ttsvibelounge-main\reddit\reddit.py", line 108, in posts
    valid_submissions = get_valid_submissions(submissions)
  File "c:\Users\Downloads\ttsvibelounge-main\reddit\reddit.py", line 96, in get_valid_submissions
    for submission in submissions:
  File "C:\Users\AppData\Local\Programs\Python\Python310\lib\site-packages\praw\models\listing\generator.py", 
line 63, in __next__
    self._next_batch()
  File "C:\Users\AppData\Local\Programs\Python\Python310\lib\site-packages\praw\models\listing\generator.py", 
line 89, in _next_batch
    self._listing = self._reddit.get(self.url, params=self.params)
  File "C:\Users\AppData\Local\Programs\Python\Python310\lib\site-packages\praw\util\deprecate_args.py", line 
43, in wrapped
    return func(**dict(zip(_old_args, args)), **kwargs)
  File "C:\Users\AppData\Local\Programs\Python\Python310\lib\site-packages\praw\reddit.py", line 634, in get  
    return self._objectify_request(method="GET", params=params, path=path)
  File "C:\Users\AppData\Local\Programs\Python\Python310\lib\site-packages\praw\reddit.py", line 739, in _objectify_request
    self.request(
  File "C:\Users\AppData\Local\Programs\Python\Python310\lib\site-packages\praw\util\deprecate_args.py", line 
43, in wrapped
    return func(**dict(zip(_old_args, args)), **kwargs)
  File "C:\Users\AppData\Local\Programs\Python\Python310\lib\site-packages\praw\reddit.py", line 941, in request
    return self._core.request(
  File "C:\Users\AppData\Local\Programs\Python\Python310\lib\site-packages\prawcore\sessions.py", line 330, in request
    return self._request_with_retries(
  File "C:\Users\AppData\Local\Programs\Python\Python310\lib\site-packages\prawcore\sessions.py", line 228, in _request_with_retries
    response, saved_exception = self._make_request(
  File "C:\Users\AppData\Local\Programs\Python\Python310\lib\site-packages\prawcore\sessions.py", line 185, in _make_request
    response = self._rate_limiter.call(
  File "C:\Users\AppData\Local\Programs\Python\Python310\lib\site-packages\prawcore\rate_limit.py", line 33, in call
    kwargs["headers"] = set_header_callback()
  File "C:\Users\AppData\Local\Programs\Python\Python310\lib\site-packages\prawcore\sessions.py", line 283, in _set_header_callback
    self._authorizer.refresh()
  File "C:\Users\AppData\Local\Programs\Python\Python310\lib\site-packages\prawcore\auth.py", line 373, in refresh
    self._request_token(
  File "C:\Users\AppData\Local\Programs\Python\Python310\lib\site-packages\prawcore\auth.py", line 155, in _request_token
    response = self._authenticator._post(url, **data)
t
    response = self._requestor.request(
  File "C:\Users\AppData\Local\Programs\Python\Python310\lib\site-packages\prawcore\requestor.py", line 62, in request
    raise RequestException(exc, args, kwargs)
prawcore.exceptions.RequestException: error with request Invalid leading whitespace, reserved character(s), or returncharacter(s) in header value: ' PRAW/7.6.0 prawcore/2.3.0'
PS C:\Users\Downloads\ttsvibelounge-main>  c:; cd 'c:\Users\Desktop\ttsvibelounge-main'; & 'C:\Users\AppData\Local\Programs\Python\Python310\python.exe' 'c:\Users\.vscode\extensions\ms-python.python-2022.18.2\pythonFiles\lib\python\debugpy\adapter/../..\debugpy\launcher' '57377' '--' 'c:\Users\Desktop\ttsvibelounge-main\app.py' 
##### YOUTUBE REDDIT BOT #####
OS Version     : Windows 10
Python Version : 3.10.5 (tags/v3.10.5:f377153, Jun  6 2022, 16:14:13) [MSC v.1929 64 bit (AMD64)]
2022-11-10 19:48:54 INFO     Setting Orientation to :                      landscape
2022-11-10 19:48:54 INFO     Setting video_height to :                      720
2022-11-10 19:48:54 INFO     Setting video_width to :                     1280
2022-11-10 19:48:54 INFO     Setting Reddit Post Time Filter :                      day
Retrieving posts from subreddit :
askreddit+antiwork+AskMen+ChoosingBeggars+hatemyjob+NoStupidQuestions+pettyrevenge+Showerthoughts+TooAfraidToAsk+TwoXChromosomes+unpopularopinion+confessions+confession
Traceback (most recent call last):
  File "C:\Users\AppData\Local\Programs\Python\Python310\lib\site-packages\prawcore\requestor.py", line 58, in request
    return self._http.request(
  File "C:\Users\AppData\Local\Programs\Python\Python310\lib\site-packages\requests\sessions.py", line 573, in request
    prep = self.prepare_request(req)
  File "C:\Users\AppData\Local\Programs\Python\Python310\lib\site-packages\requests\sessions.py", line 484, in prepare_request
    p.prepare(
  File "C:\Users\AppData\Local\Programs\Python\Python310\lib\site-packages\requests\models.py", line 369, in prepare
    self.prepare_headers(headers)
  File "C:\Users\AppData\Local\Programs\Python\Python310\lib\site-packages\requests\models.py", line 491, in prepare_headers
    check_header_validity(header)
  File "C:\Users\AppData\Local\Programs\Python\Python310\lib\site-packages\requests\utils.py", line 1043, in check_header_validity
    _validate_header_part(value, "value", HEADER_VALIDATORS[type(value)][1])
  File "C:\Users\AppData\Local\Programs\Python\Python310\lib\site-packages\requests\utils.py", line 1048, in _validate_header_part
    raise InvalidHeader(
requests.exceptions.InvalidHeader: Invalid leading whitespace, reserved character(s), or returncharacter(s) in header value: ' PRAW/7.6.0 prawcore/2.3.0'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "c:\Users\Desktop\ttsvibelounge-main\app.py", line 315, in <module>
    for reddit_post in reddit_posts:
  File "C:\Users\AppData\Local\Programs\Python\Python310\lib\site-packages\praw\models\listing\generator.py", 
line 63, in __next__
    self._next_batch()
  File "C:\Users\AppData\Local\Programs\Python\Python310\lib\site-packages\praw\models\listing\generator.py", 
line 89, in _next_batch
    self._listing = self._reddit.get(self.url, params=self.params)
  File "C:\Users\AppData\Local\Programs\Python\Python310\lib\site-packages\praw\util\deprecate_args.py", line 
43, in wrapped
    return func(**dict(zip(_old_args, args)), **kwargs)
  File "C:\Users\AppData\Local\Programs\Python\Python310\lib\site-packages\praw\reddit.py", line 634, in get  
    return self._objectify_request(method="GET", params=params, path=path)
  File "C:\Users\AppData\Local\Programs\Python\Python310\lib\site-packages\praw\reddit.py", line 739, in _objectify_request
    self.request(
  File "C:\Users\AppData\Local\Programs\Python\Python310\lib\site-packages\praw\util\deprecate_args.py", line 
43, in wrapped
    return func(**dict(zip(_old_args, args)), **kwargs)
  File "C:\Users\AppData\Local\Programs\Python\Python310\lib\site-packages\praw\reddit.py", line 941, in request
    return self._core.request(
  File "C:\Users\AppData\Local\Programs\Python\Python310\lib\site-packages\prawcore\sessions.py", line 330, in request
    return self._request_with_retries(
  File "C:\Users\AppData\Local\Programs\Python\Python310\lib\site-packages\prawcore\sessions.py", line 228, in _request_with_retries
    response, saved_exception = self._make_request(
  File "C:\Users\AppData\Local\Programs\Python\Python310\lib\site-packages\prawcore\sessions.py", line 185, in _make_request
    response = self._rate_limiter.call(
  File "C:\Users\AppData\Local\Programs\Python\Python310\lib\site-packages\prawcore\rate_limit.py", line 33, in call
    kwargs["headers"] = set_header_callback()
  File "C:\Users\AppData\Local\Programs\Python\Python310\lib\site-packages\prawcore\sessions.py", line 283, in _set_header_callback
    self._authorizer.refresh()
  File "C:\Users\AppData\Local\Programs\Python\Python310\lib\site-packages\prawcore\auth.py", line 373, in refresh
    self._request_token(
  File "C:\Users\AppData\Local\Programs\Python\Python310\lib\site-packages\prawcore\auth.py", line 155, in _request_token
    response = self._authenticator._post(url, **data)
  File "C:\Users\AppData\Local\Programs\Python\Python310\lib\site-packages\prawcore\auth.py", line 30, in _post
    response = self._requestor.request(
  File "C:\Users\AppData\Local\Programs\Python\Python310\lib\site-packages\prawcore\requestor.py", line 62, in request
    raise RequestException(exc, args, kwargs)
prawcore.exceptions.RequestException: error with request Invalid leading whitespace, reserved character(s), or returncharacter(s) in header value: ' PRAW/7.6.0 prawcore/2.3.0'

What does this mean?

13xJ commented 1 year ago

I think the problem is because I don't have a praw user agent. How would I get that?

alexlaverty commented 1 year ago

User agent can be anything just give it a descriptive name, MyUserAgent or something.

13xJ commented 1 year ago

Yep that fixed it thanks