0

I was working on the project that I had to use Python version 2.7.11 dues to a strict customer requirement. I just became a part of another project that I have to use Python 2.7.16, again strict customer requirement.

I originally installed my 2.7.11 in C:\Python27\ on my Windows machine. With understanding that installing multiple version of Python is possible, I installed 2.7.16 in C:\Python2.7.16\ on the same machine. I selected an option not to add this new python installation to PATH.

When I opened the command window and typed python.exe, python returned below output.

C:\>python
Python 2.7.16 (v2.7.16:413a49145e, Mar  4 2019, 01:30:55) [MSC v.1500 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>>

Thinking somehow the PATH got added, I checked the PATH variable, but it does not show the new path.

I tried to find out what is really running, but it was the installation of my old python, 2.7.11.

C:\>python
Python 2.7.16 (v2.7.16:413a49145e, Mar  4 2019, 01:30:55) [MSC v.1500 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> sys.executable
'C:\\Python27\\python.exe'
>>>

I also tried to run my old python specifically, but the result was the same.

C:\>C:\Python27\python.exe
Python 2.7.16 (v2.7.16:413a49145e, Mar  4 2019, 01:30:55) [MSC v.1500 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>>

If I run the new installation, it looks like it correctly runs the 7.2.16 as below.

C:\>C:\Python2.7.16\python.exe
Python 2.7.16 (v2.7.16:413a49145e, Mar  4 2019, 01:30:55) [MSC v.1500 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> sys.executable
'C:\\Python2.7.16\\python.exe'
>>>

What is happening here? What version of Python am I running when I run the command "C:\Python27\python.exe"?

Did I change the version of Python installed in "C:\Python27\"? If not, why does the execution of python display the wrong version?

Kay
  • 1,235
  • 2
  • 13
  • 27
  • 1
    You should read about `docker` – Uri Goren Mar 31 '19 at 07:27
  • 1
    virtualenv? conda? – ozlevka Mar 31 '19 at 07:41
  • @ozlevka, Yes, I use the virtual environment. I have several virtual environments for my 2.7.11 installation. I am actually very worried about the contamination of the virtual environment also. I was checking the health of the installation of both 2.7.11 and 2.7.16 before I create a venv for newly installed 2.7.16. I am very concerned now...... – Kay Mar 31 '19 at 07:45
  • You can delete virtuaenv any time. You can use some analog to source command on Windows https://stackoverflow.com/a/50792493/1573395. And docker, as @Uri Goren suggest, it will be a good solution. – ozlevka Mar 31 '19 at 07:50
  • @ozlevka, what do you think it is happening? When I run python 2.7.11, why does it display 2.7.16? I checked the file dates, I know files did not get overwritten. – Kay Mar 31 '19 at 07:53
  • Consider learning how to use `pipenv` It will help you manage your projects in a sane way. – Jacek Mar 31 '19 at 08:15

0 Answers0