Prajwal Raju P
Prajwal Raju P

Reputation: 318

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

Upvotes: 7

Views: 24852

Answers (4)

Czaporka
Czaporka

Reputation: 2407

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

Upvotes: 6

lllrnr101
lllrnr101

Reputation: 2343

Use shebangs! In the first line of your script write the python interpretor path.

#! /usr/bin/python

Then chmod +x your file on shell. That will make it executable. And you can directly run it.

Upvotes: 1

fragmentedreality
fragmentedreality

Reputation: 1317

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

Upvotes: 2

Yuv_c
Yuv_c

Reputation: 118

Try running python3 Wifite2.py from the directory where the file exists.

Upvotes: 1

Related Questions