背景
我正在使用一个涉及 makefile 的包。这些 makefile 通过
/bin/sh
(SHELL = /bin/sh
中的 Makefile.common
)将 python 命令发送到终端,命令始终为 python some_script.py ...
。因此,为了这个问题,我们假设我必须坚持/bin/sh
。
问题
python-is-python3
已安装:
axel@axel-ThinkPad-X250:~$ sudo apt install python-is-python3
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
python-is-python3 is already the newest version (3.9.2-2).
0 upgraded, 0 newly installed, 0 to remove and 3 not upgraded.
python
是 python3
以及 ~/.bash_aliases
(~/.profile
) 中 alias python='python3'
的别名,并且在 /bin/bash
中起作用:
axel@axel-ThinkPad-X250:~$ /bin/bash
axel@axel-ThinkPad-X250:~$ python3
Python 3.10.12 (main, Nov 20 2023, 15:14:05) [GCC 11.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> exit()
axel@axel-ThinkPad-X250:~$ python
Python 3.10.12 (main, Nov 20 2023, 15:14:05) [GCC 11.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> exit()
但不是在
/bin/sh
:
axel@axel-ThinkPad-X250:~$ /bin/sh
$ python3
Python 3.10.12 (main, Nov 20 2023, 15:14:05) [GCC 11.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> exit()
$ python
/bin/sh: 2: python: not found
$
如何让 /bin/sh 理解 python 是 python3?
所以事实证明,用pip创建虚拟环境后,在
python
中发现了/bin/sh
。顽固的我。