Search code examples
pythonterminalpython-os

Python terminal based code is raising an : [Errno 22] Invalid argument


Hi there is a weird problem when i use terminal based stuff in Python

(I use Windows with VS Code)

My code looks like this

import os
os.system('C:/Users/.../Downloads/.../lib/python3.9/venv/scripts/nt')

But there is a very weird error:

[Errno 22] Invalid argument

The error is confusing ,before every terminal based code could work fine but now it's always showing that or sometimes this:

>>Why
>>

Solution

  • Try using double quotes and also providing the full path as an argument to the function call. e.g.

    import os
    os.system("C:/path/to/script/being/executed")