voussoir / timesearch

The subreddit archiver
BSD 3-Clause "New" or "Revised" License
172 stars 7 forks source link

SyntaxError: invalid syntax #7

Closed liner601 closed 4 years ago

liner601 commented 4 years ago

Pretty sure i'm doing this wrong but heres how it goes,

  1. python

  2. timesearch.py get_submissions -r subredditofchoice

Output: File "", line 1 timesearch.py get_submissions -r subredditofchoice ===================^ SyntaxError: invalid syntax

(Ignore the =====================s they're just there as spacers since GitHub doesn't like spaces}.

WAUthethird commented 4 years ago

Yeah, the way to do it would not to be to run Python first, as that just puts you in the shell.

You'll want to run it as python timesearch.py get_submissions -r subredditofchoice, in one command.

voussoir commented 4 years ago

Thanks @WAUthethird for responding.

@liner601, William is right, Timesearch is run from your terminal / command prompt, not from within the Python interpreter. Make sure to cd into the Timesearch folder so that you can run python timesearch.py as William described. Here's a screenshot:

image

I'll take a look at improving the readme to help people who are new to running Python programs. Feel free to close this issue when you get it working 👍

liner601 commented 4 years ago

Yeah, the way to do it would not to be to run Python first, as that just puts you in the shell.

You'll want to run it as python timesearch.py get_submissions -r subredditofchoice, in one command.

Whenever I try to use 'python timesearch.py get_submissions -r subredditofchoice' It returns a blank output, as if the command hast been run.

voussoir commented 4 years ago

I'm sorry about that, I haven't heard of this problem yet so let's try to figure it out.

Firstly, what does it show when you run python --version? Do you have multiple versions of Python installed, and the default is not 3+? Did you have any issues during the setup described here?

What happens if you do python timesearch.py --help? Then python timesearch.py get_submissions --help? Please try poking around a bit with commands like this and see if you can get some output. Try some of the other commands too. Screenshots would be appreciated if you're able to provide them.

liner601 commented 4 years ago

I'm sorry about that, I haven't heard of this problem yet so let's try to figure it out.

Firstly, what does it show when you run python --version? Do you have multiple versions of Python installed, and the default is not 3+? Did you have any issues during the setup described here?

What happens if you do python timesearch.py --help? Then python timesearch.py get_submissions --help? Please try poking around a bit with commands like this and see if you can get some output. Try some of the other commands too. Screenshots would be appreciated if you're able to provide them.

Thanks for the quick response!

Python shows my version to be 3.7.0, no duplicate installs.

Setup was actually quite easy, no hiccups there.

http://prntscr.com/s4bhd2 Theres a screenshot of my cmd prompt.

Although I've found one odd thing that may be the issue, timesearch.py was 0kbs and when I opened it with visual studio it appears theres no code within it.

Edit: aha! it seems git clone didnt work properly and messed up the timsearch.py, so now only one obstacle to face, the script is telling me to input the contact_info string into the boy.py what am I supposed to put there? cant seem to find anything mentioning that string on the Reddit tutorial.

voussoir commented 4 years ago

Although I've found one odd thing that may be the issue, timesearch.py was 0kbs and when I opened it with visual studio it appears theres no code within it.

Yep, that sounds like a problem alright!

Here's that file: https://github.com/voussoir/timesearch/blob/master/timesearch.py

If that's the only 0kb file, then copy-pasting this code back into the file should work. If any other files look broken, you can always re-download everything from the main page.

This kind of thing tends to happen when using > in the command prompt, like echo hello > timesearch.py will put the world hello into the file but delete everything else. Since my readme file uses > timesearch.py to visually represent the command prompt, I can see how this would easily cause confusion and create problems. I will make the readme more clear. Thank you for opening this issue.

liner601 commented 4 years ago

Although I've found one odd thing that may be the issue, timesearch.py was 0kbs and when I opened it with visual studio it appears theres no code within it.

Yep, that sounds like a problem alright!

Here's that file: https://github.com/voussoir/timesearch/blob/master/timesearch.py

If that's the only 0kb file, then copy-pasting this code back into the file should work. If any other files look broken, you can always re-download everything from the main page.

This kind of thing tends to happen when using > in the command prompt, like echo hello > timesearch.py will put the world hello into the file but delete everything else. Since my readme file uses > timesearch.py to visually represent the command prompt, I can see how this would easily cause confusion and create problems. I will make the readme more clear. Thank you for opening this issue.

Seems like it worked! Thanks for the quick responses and the amazing tool, Good day.