I have a unicode string. When I print it it, copy and paste it into the CMD and press Enter - it's all working well.
But When I call the function subprocess.Popen()
with that command string it doesn't work, Python says there is no such file in the path and prints a path in gibberish (the unicode part in the original string is replaced with weird looking characters).
Assume I have the string (actually a type<unicode>
) called s
(by the way, my string contains a command running a python script from an external folder, so it looks something like this - "python 'C:/path/to/file/file.py' arg1 arg2'
), I can do:
print s #this works, even just copying and pasting it manually into the command line works fantastically
subprocess.Popen(s, stdout=subprocess.PIPE) #prints 'python: can't open file [gibberish path]: Errno 2 no such file or directory'
And the reason why I don't use any other function aside of Popen()
, say system()
or call()
is because I need the output of the program.
Any idea of what I can do?