SublimeREPL icon indicating copy to clipboard operation
SublimeREPL copied to clipboard

How to Solve Error 22 (errno 22) : Invalid Arguement

Open beejay4l opened this issue 8 years ago • 4 comments

Hello guys,

I am entirely new to programming, but I'm trying to do something with Python programming. I'm trying to run open file command in Sublime Text 3 and I've been having this error. Please see below:

error file.txt

Traceback (most recent call last): File "C:\Users\Awesome God\Desktop\test.py", line 2, in file = open("C:\Users\Awesome God\Desktop\test.txt\", "r") OSError: [Errno 22] Invalid argument: 'C:\Users\Awesome God\Desktop\test.txt\' [Finished in 0.3s]

Any solution to this, please?

beejay4l avatar Sep 18 '17 08:09 beejay4l

You are trying to open a directory as a file. Remove trailing \ from path to name the File. Also Backslahes needed to be escaped, or the string must be a raw string (e.g. r"here comes a windows path")

stuertz avatar Jan 18 '18 09:01 stuertz

You also spelled Argument incorrectly :p

anthonyeleven avatar Jan 10 '20 18:01 anthonyeleven

I am also facing a similar type of issue. I have a datetime value as string. i am trying to put that string as the title of a file. but it's showing invalid argument. Can anyone please help me? Thanks in advance !!

string=radar.metadata['start_datetime']

type(string) out: str

print(string) out: 2019-02-07T00:14:24Z

pyart.io.write_grid_mdv ( '{}.mdv' .format(string),grid,mdv_field_names=None, field_write_order=None) out: OSError Traceback (most recent call last) in () ----> 1 pyart.io.write_grid_mdv('{string}.mdv' .format(string=string),grid,mdv_field_names=None, field_write_order=None)

~/anaconda3/lib/python3.7/site-packages/pyart/io/mdv_grid.py in write_grid_mdv(filename, grid, mdv_field_names, field_write_order) 220 221 # write the file --> 222 mdv.write(filename) 223 224

~/anaconda3/lib/python3.7/site-packages/pyart/io/mdv_common.py in write(self, filename, debug) 450 self.fileptr = filename 451 else: --> 452 self.fileptr = open(filename, 'wb') 453 file_start = self.fileptr.tell() 454

OSError: [Errno 22] Invalid argument: '2019-02-07T00:14:24Z.mdv

MohitDahliya avatar Sep 24 '21 11:09 MohitDahliya

On e.g. Windows : is not a valid char for a filename. Compare with e.g. c:\ where it has a special meaning

stuertz avatar Sep 26 '21 10:09 stuertz