JRodge01
JRodge01

Reputation: 280

Terminal's python version and Eclipse's python version mismatch

My MacBook came preinstalled with Python 2.7.16, and I downloaded Python 3.8.5. To my understanding, the operating system needs Python 2.x so I did not uninstall it.

Eclipse (using Pydev) is the IDE I'm using. I set up two interpreters, one for python and the other python3. I set up one project for each interpreter to make sure I set them up correctly.

The script is:

import sys
print(sys.version)

When I run it with the python interpreter, I correctly get version 2.7.16. When I run it with the python3 interpreter, I instead get 3.8.2.

Running python -V yields ``Python 2.7.16. Running python3 -VyieldsPython 3.8.5```.

Why does the interpreter return one version and the terminal another?

I'm at a loss for how to troubleshoot or fix this, or if it is a non-issue.

Upvotes: 0

Views: 591

Answers (1)

Tom
Tom

Reputation: 889

To clarify, you get the 2.7.16 and 3.8.2 versions when running your program from within Eclipse. The python -V is clearly from the command line. The interpretation is that your Eclipse environment came with its own python interpreter which happened to be 3.8.2. Have you tried running your script from the command line with python3 path/to/your/script.py? This probably gives 3.8.5. I don't see a real problem here in most cases you do not care whether you have python 3.8.2 or 3.8.5.

The "biggest" issue is a cosmetic one that you have two python3 installations which is a bit of a waste. When using additional libraries, you may find that you have to install them in your Eclipse environment and in your command line if you want to use your scripts in both environments which would be a bit tedious. If this does turn out to be a problem, check in Eclipse whether there is any way to change your python3 configuration to use the interpreter used by the command line (sorry cannot be more specific, it's a long time that I used Eclipse).

Upvotes: 1

Related Questions