Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
601 views
in Technique[技术] by (71.8m points)

linux - "‘python’: No such file or directory" when running Python file as executable

I have installed python and I have a file Wifite.py that exists in my current directory.

But whenever I try to run the Wifite2.py file I receive this error:

‘python’: No such file or directory

jarvus@jarvus:~/wifite2$ ls
bin          PMKID.md             setup.py   wordlist
Dockerfile   README.md            tests      wordlist-
EVILTWIN.md  reaver-wps-fork-t6x  TODO.md
LICENSE      runtests.sh          wifite
MANIFEST.in  setup.cfg            Wifite.py


jarvus@jarvus:~/wifite2$ ./Wifite.py
/usr/bin/env: ‘python’: No such file or directory

What changes should be made to get ./Wifite.py working?

The workaround I got is using:

python3 Wifite.py

But I'm looking for alternatives.

question from:https://stackoverflow.com/questions/65934574/python-no-such-file-or-directory-when-running-python-file-as-executable

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

This message:

/usr/bin/env: ‘python’: No such file or directory

suggests that the hashbang in your script looks like this:

#!/usr/bin/env python

Since running the script explicitly with python3 worked OK, it sounds like you're on a distro where by default you only have python3 and no python. As other answers suggest, you may install python-is-python3 (which basically creates a python symlink pointing to python3). If you don't wish to do that, then just adjust the script's hashbang so that /usr/bin/env looks for python3:

#!/usr/bin/env python3

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...