Arefe
Arefe

Reputation: 12397

Python version for the development

I would like to do some development with Python that I don't use for a while and this is always confusing about the versions. It's just one project, so, I would like to stick with Python 3 and use for everything from now on. As Mac OS come with default Python 2.7, I had to install using the brew.

$ brew install python3

Later, I export the PATH in the ~/.bash_profile using the command,

$ export PATH=/usr/local/opt/python/libexec/bin:$PATH 
$ source ~/.bash_profile 

I can see the Python version 3 from the terminal,

$ python --version
Python 3.7.2

$ pip --version
pip 19.0.2 from /usr/local/lib/python3.7/site-packages/pip (python 3.7)

As I mentioned, I would like to stick with Python 3 for any kind of development works. My question is is the Python 3 default is set for the Mac OS and will be used for the project without the need for virtualenv setup?

Upvotes: 0

Views: 172

Answers (2)

bignose
bignose

Reputation: 32279

Because Python 3 is not compatible with Python 2, you should treat them as separate run-time systems. This is made easier because Python 2 installs the command python2, Python 3 installs the command python3.

So you should use the command python2 for Python 2, and the command python3 for Python 3, and avoid the command python because it is too ambiguous.

python3 --version
python3 -m pip --version

Upvotes: 1

Mortz
Mortz

Reputation: 4879

If by default you mean the version of Python that is launched when you execute python on the terminal - you can check that with a which command

which python

And then see the version of the above output with a --version flag

If you want to set Python3 as the default (by default, I mean what I said above) - you can use an alias

alias python=/path/to/your/python3

Upvotes: 2

Related Questions