2

I'm getting this error when trying to run a Python script. Is it saying that it can't find subprocess.py? Because I found it in the location it's listing there, so I doubt that's the issue. What file can't it find?

Traceback (most recent call last):
  File "D:\Projects\PythonMathPlots\MandelbrotVideoGenerator.py", line 201, in <module>
    run( ['open', 'MandelbrotZoom.mp4'] )
  File "C:\Users\Aaron\AppData\Local\Programs\Python\Python37\lib\subprocess.py", line 472, in run
    with Popen(*popenargs, **kwargs) as process:
  File "C:\Users\Aaron\AppData\Local\Programs\Python\Python37\lib\subprocess.py", line 775, in __init__
    restore_signals, start_new_session)
  File "C:\Users\Aaron\AppData\Local\Programs\Python\Python37\lib\subprocess.py", line 1178, in _execute_child
    startupinfo)
FileNotFoundError: [WinError 2] The system cannot find the file specified
whatwhatwhat
  • 1,991
  • 4
  • 31
  • 50
  • I think maybe your `'MandelbrotZoom.mp4` file, is `D:\Projects\PythonMathPlots\MandelbrotVideoGenerator.py` on your path? – DanielAaron Sep 13 '19 at 03:38
  • probably it can't find file `open` or `MandelbrotZoom.mp4`. You may have to add full path to both. – furas Sep 13 '19 at 03:38
  • @whatwhatwhat What is the **`code`** that you ran? In order to help you with your query, it will be helpful to see the code and the error/output both. – CypherX Sep 13 '19 at 03:39
  • I'm used to `open` being a Mac thing, not a Windows thing. – John Gordon Sep 13 '19 at 03:58
  • This question is not a Sublime Text question, it's a Python question. It would be a Sublime question if the problem was that Sublime doesn't execute your script, but it's running it and the issue is in the code of the script itself. – OdatNurd Sep 13 '19 at 04:56
  • Note also that `open` is a MacOS specific command to open a file in the associated application. On Windows the equivalent command is `start`, so based on the error you're getting one issue is that you can't execute `open` because it doesn't exist on windows (Windows looks for it and can't find it). – OdatNurd Sep 13 '19 at 04:57

3 Answers3

1

You may need to put the full path in the run(...) command, to the open file, and the path to the .mp4 file as well.

Most likely, open does not exist on your system and you have to use the name of the video player software instead.

lenik
  • 23,228
  • 4
  • 34
  • 43
0

Make sure the user you're running the script as has read permission for the file.

Dylon
  • 1,730
  • 15
  • 14
0

You may also try with subprocess.Popen(args, shell=True). The use of shell=True may be useful.

Also, use a path defined as path = os.path.join(filepath, filename) and then before passing the path to Popen, assert if os.path.exists(path)==True.

But note that there are some downsides to using shell=True:

  1. Actual meaning of 'shell=True' in subprocess
  2. https://medium.com/python-pandemonium/a-trap-of-shell-true-in-the-subprocess-module-6db7fc66cdfd
CypherX
  • 7,019
  • 3
  • 25
  • 37