
Ich habe ein Skript test.py
in meinen %USERPROFILE%
Ordner gelegt:
import sys
print("TEST", sys.version_info, sys.executable)
Wenn Sie cmd
( WIN+ R) ausführen und dann test
+ eingeben ENTER, wird Folgendes zurückgegeben:
C:\Users\wittrup>test
('TEST', sys.version_info(major=2, minor=7, micro=10, releaselevel='final', serial=0), 'C:\\Python27\\python.exe')
Ich möchte, dass dies mit Python 3.6 läuft.
Es sind zwei Python-Versionen installiert:
C:\Python27\python.exe
C:\Users\wittrup\AppData\Local\Continuum\Anaconda3
echo %path:;=&echo.%
zeigt an:
C:\WINDOWS\system32
C:\WINDOWS
C:\WINDOWS\System32\Wbem
C:\WINDOWS\System32\WindowsPowerShell\v1.0\
C:\Program Files (x86)\pythonxy\SciTE-3.5.1-4
C:\Program Files (x86)\pythonxy\console
C:\Users\wittrup\AppData\Local\Microsoft\WindowsApps
C:\Users\wittrup\AppData\Local\Continuum\Anaconda3
C:\Users\wittrup\AppData\Local\Continuum\Anaconda3\Scripts
(und eine Menge anderer Dinge, die ich für diesen Fall für irrelevant hielt)
C:\Users\wittrup>echo %PATHEXT%
.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC;.PY;.PYW
Registrierung:
Computer\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\Python.exe
C:\Users\wittrup\AppData\Local\Continuum\Anaconda3\python.exe
Computer\HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\App Paths\python.exe
C:\Users\wittrup\AppData\Local\Continuum\Anaconda3\python.exe
Was mir hier ein Rätsel ist, ist, dass ich einfach nicht herausfinden kann, wie Windows es schafft, das Skript mit Python 2.6 auszuführen. Gibt es noch andere Stellen, an denen ich nachsehen kann?
C:\Users\wittrup>ver
Microsoft Windows [Version 10.0.17134.407]
Antwort1
Kann durch Frage-Kommentar gelöst werden (danke!).
; Note the detail about administrator privileges
C:\WINDOWS\system32>ASSOC .py
.py=Python.File
C:\WINDOWS\system32>FTYPE | FINDSTR Python.File
Python.File="C:\Python27\python.exe" "%1" %*
C:\WINDOWS\system32>FTYPE /?
Displays or modifies file types used in file extension associations
FTYPE [fileType[=[openCommandString]]]
fileType Specifies the file type to examine or change
openCommandString Specifies the open command to use when launching files
of this type.
; more ...
C:\WINDOWS\system32>FTYPE Python.File="python.exe" "%1" %*
Python.File="python.exe" "%1" %*
Den Rest überlasse ich den Umgebungsvariablen.