wuub / SublimeREPL

SublimeREPL - run an interpreter inside ST2 (Clojure, CoffeeScript, F#, Groovy, Haskell, Lua, MozRepl, NodeJS, Python, R, Ruby, Scala, shell or configure one yourself)
https://github.com/wuub/SublimeREPL
Other
2.14k stars 312 forks source link

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

Open beejay4l opened 7 years ago

beejay4l commented 7 years ago

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?

stuertz commented 6 years ago

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")

anthonyeleven commented 4 years ago

You also spelled Argument incorrectly :p

MohitDahliya commented 2 years ago

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
stuertz commented 2 years ago

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