0

I'm trying to learn some basics of Python integration on my Mac.

The crux of my question is: When I open my terminal and type python -V, it returns python 2.7.16. If I then type python3 -V, it returns 3.9.7.

Assumptions:

  1. I understand my Mac comes pre installed with Python 2
  2. I recently completed a beginners python YouTube course in which I downloaded python 3 as well as PyCharm.
  3. When I configure a new .py project in PyCharm, I select Python 3.9 as my interpreter.

I'm trying to bridge the mental gap and better understand the link between my terminal, PyCharm, and the different versions of Python. If I downloaded Python 3, why isn't that displaying when I type python -V in my terminal, broadly speaking?

S3DEV
  • 8,768
  • 3
  • 31
  • 42
  • When you install a new python the alias `python` isn't update to the new python version – azro Nov 13 '21 at 19:54
  • Also worth a read: https://askubuntu.com/questions/351318/changing-symlink-python-to-python3-causes-problems – rv.kvetch Nov 13 '21 at 19:57
  • Your terminal can be set up so that any command corresponds to any executable on your computer (either using `PATH` or through aliases). PyCharm can be configured to use any Python executable. You shouldn't read too much into what your terminal does by default. The important part is that `python3 -V` works and shows a Python 3 version and that whichever IDE you're using (e.g. PyCharm) is working with whichever Python version you want. – Bernhard Barker Nov 13 '21 at 20:02

1 Answers1

0

Yes , Mac comes with python2 preconfigured. And you are not seeing python3's version by default due to reason that your Path is looking for system python first which is python2. To appear python3 in your path you need to add that in your path or you can set alias too.

The recommended way not to mess with path is create a venv that is virtual environment and start using that. It will avoid any mess of system settings and will point to desired python version

John Byro
  • 674
  • 3
  • 13