2

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?

1

2 Answers 2

5

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 
Sign up to request clarification or add additional context in comments.

6 Comments

After the symlinking i get this error: xcode-select: Failed to locate 'python', requesting installation of command line developer tools.
You need to install the command line developer tools. They're just basic tools you'll need for development, regardless of language.
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?
@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.
Question: Is it necessary to create the "link_path" (not the target_path aka $(which python3)) in the /usr/local/bin directory? could you use /usr/bin or /opt or some other directory path and it would still work flawlessly?
|
2

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

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.