![]() |
Subprocess.Popen() not working when reading file path from csv file - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: Subprocess.Popen() not working when reading file path from csv file (/thread-33544.html) Pages:
1
2
|
RE: Subprocess.Popen() not working when reading file path from csv file - herwin - May-07-2021 Thanks ! Most now works using the code you mention, but not all. the csv file has these lines: C:\\Program Files\\BraveSoftware\\Brave-Browser\\Application\\brave.exe C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe C:\\Program Files (x86)\\Foxit Software\\Foxit Reader\\FoxitUpdater.exe C:\\Users\\zorin\\Documents\\Python Scripts\\test folder\\JavaUpdate.bat C:\\Users\\zorin\\Documents\\Python Scripts\\test folder\\KeepassXC Update.bat C:\\Program Files\\Tracker Software\\Update\\TrackerUpdate.exe C:\\Program Files (x86)\\2BrightSparks\\SyncBackFree\\SyncBackFree.exe C:\\Program Files\\VideoLAN\\VLC\\vlc.exe C:\\Users\\zorin\\Documents\\Python Scripts\\test folder\\windowsupdate.bat C:\\Users\\zorin\\AppData\\Roaming\\Zoom\\bin\\Zoom.exe The code works fine for all lines, except 2: SyncbackFree (7) vlc.exe (8) if I chose either of these from my menu I get this error message: I copied the line from the csv into a command prompt and the programs open fine, so I know the paths and file names are correct.Any suggestions why these two give an error message and it works for the rest? RE: Subprocess.Popen() not working when reading file path from csv file - Gribouillis - May-07-2021 Ask Python to print(repr(prg)) before it attempts to execute each program with subprocess.Popen()
RE: Subprocess.Popen() not working when reading file path from csv file - ibreeden - May-07-2021 I still believe something is going wrong with the interpretation of special characters. For example: you can insert a "vertical tab" by asigning the literal: "\v". See this: >>> print("C:\\Program Files\\VideoLAN\\VLC\\vlc.exe") C:\Program Files\VideoLAN\VLC\vlc.exe >>> print("C:\Program Files\VideoLAN\VLC\vlc.exe") C:\Program Files\VideoLAN\VLC lc.exe >>> print("C:\\Program Files (x86)\\2BrightSparks\\SyncBackFree\\SyncBackFree.exe") C:\Program Files (x86)\2BrightSparks\SyncBackFree\SyncBackFree.exe >>> print("C:\Program Files (x86)\2BrightSparks\SyncBackFree\SyncBackFree.exe") C:\Program Files (x86)BrightSparks\SyncBackFree\SyncBackFree.exeIn the first example ("C:\Program Files\VideoLAN\VLC\vlc.exe") you see the "\v" is replaced by a "vertical tab". In the second example ("C:\Program Files (x86)\2BrightSparks\SyncBackFree\SyncBackFree.exe") you can see the "\2" is replaced by ... I don't know. It disappeared. Apparently it is seen as an octal code. See String literals to see how backslashes are handled. Could it be something like this is happening when assigning literals to strings? I believe it is allowed in Python for Windows to use the forward slash instead of the backslash in folder paths. Perhaps you can try that. RE: Subprocess.Popen() not working when reading file path from csv file - herwin - May-07-2021 Thanks for all your help. When printing the path before the subprocess.popen I noticed that in the file paths for the two programs where it did not work the space between 'Program' and 'Files' was replaced with '\xa0' When I manually retyped the files paths in the csv file that was fixed and now it works fine. Thanks again |