简体   繁体   中英

FileNotFoundError: [Errno 2] No such file or directory: 'python': 'python' while running a python script

While trying to run a python script on EC2 (running ubuntu), I'm getting this error:

Traceback (most recent call last):
  File "128d.py", line 9, in <module>
    "--pca_params", "./vggish_pca_params.npz"])
  File "/usr/lib/python3.6/subprocess.py", line 267, in call
    with Popen(*popenargs, **kwargs) as p:
  File "/usr/lib/python3.6/subprocess.py", line 709, in __init__
    restore_signals, start_new_session)
  File "/usr/lib/python3.6/subprocess.py", line 1344, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: 'python': 'python'

All the dependencies are installed. I've tested the script on my home machine (Windows 10), and it works just fine. I can see that something is wrong with python installed on the EC2 machine, probably. But I didn't manage to find an answer on the web.

I've fixed the problem.

Turns out, I had my python installed in a folder that was named python3 . So, when the suprocess.py file tried to find python in path , it wasn't there.

I've renamed python3 in /usr/bin/ to python and the problem is fixed.

PS However, keep in mind, that it might raise some other issues. When I tried to aws s3 cp , it was looking for python3 instead. Maybe adding another copy of that folder as python3 would help.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM