We help IT Professionals succeed at work.

python error in my execution of a script

finnstone asked
Hi hoping someone can help as i need help debugging my python script...I do not think I am referencing my file location correctly...

see screenshot attached to see the error

see instructions for script below that were given to me

I have taken the liberty of renaming the input directory so that it doesn’t have embedded spaces; while not strictly necessary, this will reduce problems with command line execution. Command lines can easily mis-understand file names with spaces as multiple inputs, rather than just one. Also, i you need to specify a non-local path (i.e. not in the same directory as the programs), please use forward slashes (/) not the old Windows backwards slashes (\).
Watch Question

Perhaps you can try that screen capture again with the lines folded so we can see the actual command that you typed. I don't think anyone's going to be able to help much when necessary information is scrolled off to the right.


Is "extract_handles.py" a script you wrote. I didn't see any hits on Google.

As best I can see, the error message is saying that the number or form of the parameters you passed to the script does not match the way the main routine of the script was declared.


Yes someone wrote it for me

I think you are right but I don't know how to do it

I did try and follow his structions

Email me finnstones Gmail I'll send code to you

You have spaces in your file path.  That isn't going to work, you'll need to enclose that path in doubke quotes to get it to work.  Otherwise python will consider it two arguments.


got same error doing this

C:/Users/rob/Dropbox/xxxxxx/email launch/tweets/csvfiles"
What happens if you pass "../csvfiles" as the parameter?

[Those last two posts of yours look like they may have been garbled in different ways.]


same error. but not sure that is the right file reference?

the file structure is

input files
C:\Users\rob\Dropbox\xxxxx\email launch\tweets\csvfiles

python code
C:\Users\rob\Dropbox\xxx\email launch\tweets\programs-delivered4
I'll confess that I am mystified by what the @args('dirpath') line supposed to do, as well as several other things in the lines below it.

I commented out that line and changed the line


to read


and ran it against some sample data I created based on the description in the code of what it was expecting. This at least reads the files and starts extracting handles -- but it blows up later.

I'm afraid you'll need to get someone more expert in Python to get you further than this.


ok thanks!
I see that @arg is coming from the argh package, but I don't think it has been used correctly. My Python is quite old and rusty by at least 10 years, so when something is not looking/working the way I expect it to, I can't always say with authority that it's wrong -- it could just be something I haven't kept up with.