/usr/bin/env:'python':没有这样的文件或目录

/usr/bin/env:'python':没有这样的文件或目录

我正在尝试安装Windows Ubuntu Bash 上的 Gitlab 开发工具包

$python3输出

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输出

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

当我尝试这样做时:

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

这是之后的输出./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

没有输出

我该如何解决这个问题?我是 Ubuntu 新手。

答案1

对于 Ubuntu 20.04,您可以使用以下软件包进行python命令。它是 Python 3。

sudo apt install python-is-python3

包裹描述:

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.

答案2

问题场景

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

可能的解决方案 #1

如果没有安装 Python 3,请安装:apt-get install python3

可能的解决方案 #2

如果已经安装了Python 3,请运行以下命令:whereis python3

然后我们创建它的符号链接:sudo ln -s /usr/bin/python3 /usr/bin/python

答案3

安装后我遇到了同样的问题Ubuntu 18.04并尝试运行一些 python 脚本。

我试过:

sudo apt-get install python2.7-minimal

但我仍然遇到同样的错误。我通过以下方法解决了它:

sudo apt install python-minimal

答案4

您似乎已经python3安装了,但它并没有被调用python,而且无论如何您想要运行的脚本(configure)需要 python 2。所以:

  1. 安装 python2

    sudo apt-get install python2.7-minimal
    
  2. 再次运行

    ./configure
    

如果再次失败,请明确使用 python2 调用它:

/usr/bin/python2.7 configure

相关内容