sys.version_info
and sys.version
contain the version of Python that is being run. sys.executable
contains the path to the specific interpreter running.
Python3:
>>> import sys
>>> sys.version_info
sys.version_info(major=3, minor=4, micro=3, releaselevel='final', serial=0)
>>> sys.version
'3.4.3 (default, Nov 17 2016, 01:08:31) \n[GCC 4.8.4]'
>>> sys.executable
'/usr/bin/python3'
Python2:
>>> import sys
>>> sys.version_info
sys.version_info(major=2, minor=7, micro=6, releaselevel='final', serial=0)
>>> sys.version
'2.7.6 (default, Oct 26 2016, 20:30:19) \n[GCC 4.8.4]'
>>> sys.executable
'/usr/bin/python2'
The problem seems to be that your registry editor has set a different version set to run "on-click" for Python executables. You can fix that by running the Python installer for the version you want, and setting it to repair, or modifying "HKEY_CLASSES_ROOT\Python.File\Shell\open\command" to run the correct python executable (Should be "C:\Windows\py.exe"). See this image for where to find it.
If you are already using py.exe, adding a hashbang to the top of the file (#!Python<version>
, or to work with Unix executables, #!/usr/bin/env python<version>
) should help py.exe pick the correct executable to run.
To install using pip for a specific executable, run Path\To\Executable -m pip install <module>
.
To use modules from a different site-path, add the directory to the PYTHONPATH environment variable. Using import <file>
will check for modules in directories in the PYTHONPATH.