Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"‘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.

like image 445
Prajwal Raju P Avatar asked Jul 27 '26 08:07

Prajwal Raju P


2 Answers

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
like image 138
Czaporka Avatar answered Jul 28 '26 20:07

Czaporka


Seems you don't have python2 installed but only python3 but it is not registered as plain python. Try

which python
which python2
which python3

If only the last command runs without error you can try to link python3 to python with

sudo apt-get install python-is-python3
like image 44
fragmentedreality Avatar answered Jul 28 '26 20:07

fragmentedreality