Choosing Python Versions

Working with multiple versions of python

Python’s Core Developer team is regularly updating it, just to make Python more robust and remove some of bugs which comes up or are reported by Python Developers.

Owing to this reason, most people just download and setup newer version of Python on their laptop or PC. But did not give any attention to already installed version which they have. Becuase of this people sometimes end up with multiple versions of Python being installed.

If you don’t know how to setup Python read this guide made by me – Step by Step Python Installation Guide.

To be specific, you don’t need to worry much about having different versions of Python. As for running any program/code which you developed, you can just specify the version of Python which you want to use. For example – If you have both Python2.7 and Python3.9 on your laptop/PC then to run program just specify version like Python2.7 program.py or Python3.9 program.py

Note – If you just type python program.py then program would be run by using default version of Python which is in PATH of your operating system.

How to check which version of Python, I have on my PC?

For checking out which version of Python is set to default in your PC, just use which python command. This would spit out current default version of Python.

  • For checking default version – “which python”
  • For checking all of Python versions – “ls -l /usr/bin/python*”

If you have multiple versions, that’s totally fine. You don’t need to worry about it, just make sure while running program to select right version.

Should I remove python2.7 on Mac?

For those of you, who got Mac may have noticed that default version on Mac for Python is 2.7. Even Mac laptops bought after release of Python3.9 still have older 2.7 version.

Well it’s because of Apple, there’s some internal code in Operating System which runs on Python2.7, company still have not updates those internal utilities to run on newer versions of Python.

But be cautious you should not remove Python2.7 from Mac as this may break some of internal functionalities leading to decrease in performance of your laptop or may even break it’s software.

Should you add Python new version to Mac’s PATH?

A lot of my friends developers have often come to ask me about this. That whether they should add newer version to PATH rather than having Python2.7, my clear answer is no. You should not add newer version to PATH rather just add new version number to the end of python keyword while running the program. That’s super easy.

Related Posts

Leave a Reply

Your email address will not be published. Required fields are marked *