[Tutor] Argparse Error
x64 Based PC Windows 10 Home Version 1803 OS Build 17134.191 Python 3.7.0 x32 Hello I am trying to glitch video files for artistic purposes by using a scrip I found on Reddit (linked below). This is the first time I have tried to use Python and I need some help with an error that I keep getting after I input this first part of the script import argparse parser = argparse.ArgumentParser(description="Shift bytes in a file") parser.add_argument("file", help="input file") parser.add_argument("-o", "--output", help="output file") parser.add_argument("-i", "--interval", help="byte interval", default=1000) parser.add_argument("-s", "--shift", help="size of shift", default=4) parser.add_argument("-k", "--skip", help="size of initial skip offset", default=128) args = parser.parse_args() the error says : error: the following arguments are required: file I am trying to follow a post on Reddit https://www.reddit.com/r/glitch_art/comments/5o7irq/i_compiled_a_compendium_of_corruption_effects_on/ with the script that was provided in the comments https://github.com/v0x76/GlitchTools/blob/master/bytsh.py Any help would be appreciated greatly and thank you for your time. ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Argparse Error
Okay so I downloaded and saved the script as a .py file in a folder named Python on the D; Drive, and also moved my video file to a folder in my D: drive with the name Video. I tried using it in Command Prompt, Python, and Python IDLE, but I got the same error saying SyntaxError: unexpected character after line continuation character I know this is probably user error, but I am a complete novice so I need a little more explanation than "provide a file argument" please. I need to know how exactly to implement the file argument you provided. Thank you again and sorry for the misunderstanding. On Sun, Aug 12, 2018 at 2:45 AM, Alan Gauld via Tutor wrote: > On 12/08/18 00:51, Nathan Johnson wrote: > > > Hello I am trying to glitch video files for artistic purposes by using a > > scrip I found on Reddit (linked below). This is the first time I have > tried > > to use Python and I need some help with an error that I keep getting > after > > I input this first part of the script > > The error is not with the Python code but with the way you are > running the script. > > > the error says > > > > : error: the following arguments are required: file > > It is telling you that you need to provide a file argument. > Something like: > > C:\WINDOWS\PROMPT> python D:\Python\myscript.py D:\Image\myfile.img > > That's what all the argparse stuff is there for, to ensure > that Python can read and understand the arguments that > are passed when you run the script. > > The script as it stands does nothing except check the arguments. > It does nothing with those arguments. > > -- > Alan G > Author of the Learn to Program web site > http://www.alan-g.me.uk/ > http://www.amazon.com/author/alan_gauld > Follow my photo-blog on Flickr at: > http://www.flickr.com/photos/alangauldphotos > > > ___ > Tutor maillist - Tutor@python.org > To unsubscribe or change subscription options: > https://mail.python.org/mailman/listinfo/tutor > ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Argparse Error
Here is what comes out when I use the command for each program. Command Prompt: C:\Users\natha> C:\WINDOWS\PROMPT> python D:\Python\bytsh.py D:\Video\test.mp4 'C:\WINDOWS\PROMPT' is not recognized as an internal or external command, operable program or batch file. Python 32x: >>> C:\WINDOWS\PROMPT> python D:\Python\bytsh.py D:\Video\test.mp4 File "", line 1 C:\WINDOWS\PROMPT> python D:\Python\bytsh.py D:\Video\test.mp4 SyntaxError: unexpected character after line continuation character >>> Python IDLE: >>> C:\WINDOWS\PROMPT> python D:\Python\bytsh.py D:\Video\test.mp4 SyntaxError: unexpected character after line continuation character >>> which program should I be running this through? On Sun, Aug 12, 2018 at 12:24 PM, Alan Gauld via Tutor wrote: > On 12/08/18 16:52, Nathan Johnson wrote: > > Okay so I downloaded and saved the script as a .py file in a folder named > > Python on the D; Drive, and also moved my video file to a folder in my D: > > drive with the name Video. I tried using it in Command Prompt, Python, > and > > Python IDLE, but I got the same error saying > > > > SyntaxError: unexpected character after line continuation character > > This is a Python error. I suspect you only get this when trying > to run it from IDLE or inside the Python interpreter. Not from > the OS command prompt? Its caused by the \ characters which > Python sees as line continuation characters. > > But you should always send us the complete error message not > just the last line. Although it looks like gobbldegook it is > actually full of useful data. > > But for now I suspect this is all irrelevant to your problem. > Instead follow the suggestion below... > > > I know this is probably user error, but I am a complete novice so I need > a > > little more explanation than "provide a file argument" please. I need to > > know how exactly to implement the file argument you provided. > > An "argument" is just the value that you give to a command. > So a file argument is just the path to a file. You need to > provide that when you execute the command. > > That's what I was showing you here: > > >> C:\WINDOWS\PROMPT> python D:\Python\myscript.py D:\Image\myfile.img > > It says: > > Use the Windows CMD prompt and > > Type > > python > > followed by > > the path to your script file > > followed by > > the path to your image/video file > > The last bit (or lack of) is what will generate the file error. > > > -- > Alan G > Author of the Learn to Program web site > http://www.alan-g.me.uk/ > http://www.amazon.com/author/alan_gauld > Follow my photo-blog on Flickr at: > http://www.flickr.com/photos/alangauldphotos > > > ___ > Tutor maillist - Tutor@python.org > To unsubscribe or change subscription options: > https://mail.python.org/mailman/listinfo/tutor > ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor