0

The command python is not found.

This is where python3 is installed.

~ which python3
/usr/bin/python3

How do I get the command python to mean python3?

2 Answers2

0

You can add an alias in your shell.

NOTE: be careful with this, though, because if you're using a virtual environment, it doesn't always play nice with aliases you've defined outside the environment.

For example, if you use bash, you can add the following line to your ~/.bashrc file:

alias python=python3

Source: https://stackoverflow.com/a/35435574/11411191

0

You can either create an alias in your shell or symlink the python3 binary to python. Symlinking is easier and will work no matter which shell or virtual environment you are using. Just run this command:

ln -s $(which python3) /usr/local/bin/python
Michael M.
  • 10,486
  • 9
  • 18
  • 34
  • 2
    After the symlinking i get this error: `xcode-select: Failed to locate 'python', requesting installation of command line developer tools.` – Bear Bile Farming is Torture Aug 16 '22 at 20:12
  • You need to install the command line developer tools. They're just basic tools you'll need for development, regardless of language. – Michael M. Aug 16 '22 at 21:10
  • 1
    Why would you need to install developer tools? If `python3` works fine, and `/usr/local/bin/python` is symlinked to the same binary, why shouldn't that just work? – Ben Davis Oct 20 '22 at 02:16
  • @BenDavis Even if `python3` is found, installing the developer tools can't hurt. At least on my machine, the developer tools link `python` to Python 2.7.16. This answer should be an extension of what the developer tools give you. – Michael M. Oct 20 '22 at 02:44