64

I am trying to install Gitlab Development Kit on Windows Ubuntu Bash.

$python3 output

Python 3.5.2 (default, Nov 17 2016, 17:05:23)
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>

$python output

The program 'python' can be found in the following packages:
 * python-minimal
 * python3
Try: sudo apt install <selected package>

When I try to do this:

sudo apt-get install build-essential 
./configure 
make -j4 # adjust according to your available CPU capacity 
sudo make install

This is the output after ./configure

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

$ python --version 

The program 'python' can be found in the following packages:
 * python-minimal
 * python3
Try: sudo apt install <selected package>

$which -a python

no output

How can I solve this? I am new to Ubuntu.

TRiG
  • 1,960
  • 2
  • 18
  • 39
mertselimb
  • 765
  • 1
  • 5
  • 9
  • 2
    Please [edit] your question and show us the output of these commands: i) `python --version`; ii) `which -a python`. – terdon Aug 04 '17 at 08:39
  • 1
    That doesn't make sense. You said " it starts python as it should", but your output shows you don't have python installed. Did you actually run `python2` or something? – terdon Aug 04 '17 at 09:03
  • My bad i used `$ alias python=python3` before writing python that time after reopening its gone altought it didn't solved the problem – mertselimb Aug 04 '17 at 09:07
  • Please [edit] your question and clarify. Do you or do you not have python installed? What happens if you run `python` from the command line? Do you mean you only have `python3` installed? – terdon Aug 04 '17 at 09:10
  • I edited the question – mertselimb Aug 04 '17 at 09:20

9 Answers9

94

For Ubuntu 20.04 you can use following package to python command. And it is python 3.

sudo apt install python-is-python3

Description of the package:

Description: symlinks /usr/bin/python to python3

 Starting with the Debian 11 (bullseye) and Ubuntu 20.04 LTS (focal)
 releases, all python packages use explicit python3 or python2
 interpreter and do not use unversioned /usr/bin/python at all. Some
 third-party code is now predominantly python3 based, yet may use
 /usr/bin/python.
 .
 This is a convenience package which ships a symlink to point
 the /usr/bin/python interpreter at the current default python3. It may
 improve compatibility with other modern systems, whilst breaking some
 obsolete or 3rd-party software.
Pablo Bianchi
  • 14,308
  • 4
  • 74
  • 117
Dinuka Thilanga
  • 1,041
  • 7
  • 5
31

Problem scenario:

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

Possible Solution #1

If Python 3 is not installed, install it: apt-get install python3

Possible Solution #2

If Python 3 has been installed, run these commands: whereis python3

Then we create a symlink to it: sudo ln -s /usr/bin/python3 /usr/bin/python

  • 2
    Worked for me in Lubuntu 20.04, and solved my problem. Thanks! – Munsko Jun 10 '20 at 01:46
  • Solution 2 worked on Kali linux, thank you – Alexandre Elshobokshy Feb 27 '21 at 20:11
  • Not a good solution, it has the presumption that the required Python version is version 3, which might not be always the case. Better approach would be using `update-alternatives` with higher priority for Python3 and with less priority for Python2. – aderchox Nov 25 '21 at 09:50
19

I had the same problem after installing Ubuntu 18.04 and trying to run some python scripts.

I tried:

sudo apt-get install python2.7-minimal

but I still got the same error. I solved it by:

sudo apt install python-minimal
Stephen Rauch
  • 1,156
  • 6
  • 14
  • 20
nwaweru
  • 291
  • 2
  • 7
9

Yet Another Solution:

$ sudo update-alternatives --install /usr/bin/python python /usr/bin/python3 10
update-alternatives: using /usr/bin/python3 to provide /usr/bin/python (python) in auto mode

Tested & verified on my 20.04LTS system. See man update-alternatives for details. And, "No - it's not necessary to have Python2 installed for this to work."

deWalker
  • 381
  • 5
  • 9
9

You do seem to have python3 installed, but it isn't called python and anyway the script you want to run (configure) requires python 2. So:

  1. Install python2

    sudo apt-get install python2.7-minimal
    
  2. Run it again

    ./configure
    

If that fails again, call it with python2 explicitly:

/usr/bin/python2.7 configure
Wassim Dhif
  • 148
  • 6
terdon
  • 98,183
  • 15
  • 197
  • 293
7

I had the same problem, It got solved by linking python to python2.7 with the following commands

cd /usr/bin
sudo mv python python.bak
sudo ln -s /usr/bin/python2.7 /usr/bin/python
Félicien
  • 1,163
  • 1
  • 10
  • 18
Ranjan Ravee
  • 71
  • 1
  • 2
  • 1
    Worked for python3 as well, while trying to install youtube-dl. I did not want to install another version ... Simple way to just link instead – Amit Feb 09 '19 at 02:56
2

If you don't want to mess up with your system configuration, you can just replace the first line of your configure file

  1. Open it with your favorite text editor
  2. Replace #!/usr/bin/env python with #!/usr/bin/env python3
  3. Save and keep playing!
Joshua Salazar
  • 417
  • 1
  • 4
  • 14
1

Just for reference... I had a similar issue - running a python script from the docker container failed with "No such file or directory", my solution was to force Unix style line endings on the checkout of the code and in the IDE (as it was bind-mounted from the Windows host to the container).

Rots
  • 111
  • 2
1

Check the spelling in the first line. Trailing spaces have been known to prevent the shell from locating the shell...

"#!/usr/bin/env tclsh "

The training space confused bash.

Eliah Kagan
  • 116,445
  • 54
  • 318
  • 493
Richard
  • 111
  • 2