Quantcast
Channel: Active questions tagged ubuntu - Stack Overflow
Viewing all articles
Browse latest Browse all 5956

Alias python to python3 in /bin/sh

$
0
0

Context

I'm using a package involving makefiles. Those makefiles send python commands to the terminal via /bin/sh (SHELL = /bin/sh in Makefile.common), the commands are always python some_script.py .... So for the sake of this question, let's assume I have to stick to /bin/sh.

The issue

python-is-python3 is installed:

axel@axel-ThinkPad-X250:~$ sudo apt install python-is-python3Reading package lists... DoneBuilding dependency tree... DoneReading state information... Donepython-is-python3 is already the newest version (3.9.2-2).0 upgraded, 0 newly installed, 0 to remove and 3 not upgraded.

python is an alias for python3 in ~/.bash_aliases as well as in ~/.profile (alias python='python3') and is functional in /bin/bash:

axel@axel-ThinkPad-X250:~$ /bin/bashaxel@axel-ThinkPad-X250:~$ python3Python 3.10.12 (main, Nov 20 2023, 15:14:05) [GCC 11.4.0] on linuxType "help", "copyright", "credits" or "license" for more information.>>> exit()axel@axel-ThinkPad-X250:~$ pythonPython 3.10.12 (main, Nov 20 2023, 15:14:05) [GCC 11.4.0] on linuxType "help", "copyright", "credits" or "license" for more information.>>> exit()

But not in /bin/sh:

axel@axel-ThinkPad-X250:~$ /bin/sh$ python3Python 3.10.12 (main, Nov 20 2023, 15:14:05) [GCC 11.4.0] on linuxType "help", "copyright", "credits" or "license" for more information.>>> exit()$ python/bin/sh: 2: python: not found$ 

How can I get /bin/sh to understand that python is python3?


Viewing all articles
Browse latest Browse all 5956

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>