7

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.

4
  • 1
    try python Wifite2.py Commented Jan 28, 2021 at 9:48
  • try using python3 Wifinite2.py, it seems that you have some misconfiguration between python2 and python3 Commented Jan 28, 2021 at 9:51
  • 2
    How did you install Python? It seems that env can't find it in your default PATH. If you installed it through sudo apt install python3 or similar, that shouldn't be happening. Commented Jan 28, 2021 at 9:53
  • Try sudo apt-get install python-is-python3 Commented Jan 28, 2021 at 9:59

4 Answers 4

6

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
Sign up to request clarification or add additional context in comments.

3 Comments

Thanks, mate, what I ended up doing was changing the hashbang to "/usr/bin/env python" to "/usr/bin/env python3" in my python file and it solved the issue
ln -s /usr/bin/python3 /usr/local/bin/python Use this
2

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

1 Comment

Don't. If it's python3, then use python3 (in the shebang, when running scripts, ex). The OS may rely on python being an actual Python 2.
1

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

4 Comments

yes I got that working using this command but is there a way to get it working without passing the python command
No. Basically you are expecting your os to guess what to do with the file called "Wifite2.py". You could python3 Wifite2.py, you could vim Wifite2.py etc. If you want to run the script, you must specify it.
@Yuv_c in Unix-like systems, shebang tells the OS exactly what program it should use to interpret the file. OP does have one in the script, as can be seen from the error message. Not having a shebang and still trying to execute the script like this is another story though - in that case the OS does indeed have to guess what to execute the script with, AFAIK its guess is usually /bin/sh.
I wasn't aware of that @Czaporka. Thanks for the explanation.
1

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.

2 Comments

The shebang can also be /usr/local/bin/python3 (or whatever is the output of which python3) if that is what is available on the system.
Yes it can. Any interpreter you want.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.