D:\>python
Python 3.8.13 (default, May 20 2022, 16:23:54) [MSC v.1916 64 bit (AMD64)] :: Intel Corporation on win32
Warning:
This Python interpreter is in a conda environment, but the environment has
not been activated. Libraries may fail to load. To activate this environment
please see https://conda.io/activation
Type "help", "copyright", "credits" or "license" for more information.
Intel(R) Distribution for Python is brought to you by Intel Corporation.
Please check out: https://software.intel.com/en-us/python-distribution
>>>
但 python3 確實不存在
D:\>python3
'python3' is not recognized as an internal or external command,
operable program or batch file.
原來,Windows Store 自己默默(?) 拉了兩條路徑給 python.exe 和 python3.exe,它們默認安裝在%USERPROFILE%\AppData\Local\Microsoft\WindowsApps。
這邊可以透過在 Windows search prompt 裡輸入 manage app execution aliases 看到開關,這邊最好關掉避免干擾。
c:\Windows\system32>python3
Python 3.8.8 (tags/v3.8.8:024d805, Feb 19 2021, 13:18:16) [MSC v.1928 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>>
失敗的話,則會看到以下:
c:\Windows\system32>python3
Python path configuration:
PYTHONHOME = (not set)
PYTHONPATH = (not set)
program name = 'python3'
isolated = 0
environment = 1
user site = 1
import site = 1
sys._base_executable = 'C:\\Windows\\system32\\python3.exe'
sys.base_prefix = 'C:\\IntelSWTools\\system_debugger\\2234-nda\\tools\\python38'
sys.base_exec_prefix = 'C:\\IntelSWTools\\system_debugger\\2234-nda\\tools\\python38'
sys.executable = 'C:\\Windows\\system32\\python3.exe'
sys.prefix = 'C:\\IntelSWTools\\system_debugger\\2234-nda\\tools\\python38'
sys.exec_prefix = 'C:\\IntelSWTools\\system_debugger\\2234-nda\\tools\\python38'
sys.path = [
'C:\\IntelSWTools\\system_debugger\\2234-nda\\tools\\python38\\python38.zip',
'.\\DLLs',
'.\\lib',
'C:\\Windows\\system32',
]
Fatal Python error: init_fs_encoding: failed to get the Python codec of the filesystem encoding
Python runtime state: core initialized
ModuleNotFoundError: No module named 'encodings'
Current thread 0x0000dda8 (most recent call first):
<no Python frame>
表示 python3 指到 ‘C:\Windows\system32\python3.exe’ 只要修正路徑後就會正常了。(如果有建立了錯誤的 symbolic link 也要先刪掉)
NOTE
Windows 10 是透過所謂 App Execution Aliases 技術將 python.exe、python3.exe 等執行檔導向 Microsoft Store Python 安裝。其位置在 C:\User*username*\AppData\Local\Microsoft\WindowsApp。