Miguel Cardoso
Miguel Cardoso

Reputation: 69

How does python version affects the usage of modules?

I am a beginner at python, I was on my macOS Mojave 10.14.6 and found out that there are two versions of python currently installed. Typing which python or which python3, I found out two different paths to use as interpreter /usr/bin/python and /usr/local/bin/python3, which one should I use and how that affects the modules I have to use? I was trying to perform a simple calculation print("5+4=",5+4) and discovered that I must need a package using the first path.

Thank you

Upvotes: 0

Views: 292

Answers (1)

Miscellaneous
Miscellaneous

Reputation: 398

Short answer:
Use python3. i.e. /usr/local/bin/python3

Their versions are different. /usr/bin/python is python 2.x, and /usr/local/bin/python3 is python 3.x.

You can check the python version using following commands in your terminal:

python --version
python3 --version

Some of their syntaxs are different. A quick search with your favourite search engine can lead you to many detailed comparisons between python 2 and 3. For example, Python 2 or 3? Beginners shouldn't care!.

Python 2 is no longer under development since January 2020 (See Sunsetting Python 2). If you have a choice, it's better to use python 3.

Upvotes: 1

Related Questions