Unable to find file or directory Python subprocess -


I am trying to call a Python module but the following error "test.sh not found"

< P> but this file is found in the directory.

  process = subprocess. Popin ("test.sh", shell = true)  

The script and sh file are located in the same directory.

By default the current directory is not in the pat only "test.sh" Not Found, Minimum Change "./ test.sh" .

is to use. , Make sure you have legitimate Shebang, #! / Bin / sh and the executable permissions for the file ( chmod u + x test.sh ).

If you are running a Python script from a different directory, you also need to provide a full path:

  #! / Usr / bin / env python import os import import subprances from the import check_roll script_dir = os.path.realpath (os.path.dirname (sys.argv [0])) check_call (Os.path.join (script_dir, "test. Sh "))  

Note: there is no shell = True which starts the extra unnecessary shell process here realpath resolution To solve, you use the abspath instead if you want a symlink of the path relative to the script instead of the script file.


Comments

Popular posts from this blog

import - Python ImportError: No module named wmi -

Editing Python Class in Shell and SQLAlchemy -

c# - MySQL Parameterized Select Query joining tables issue -