简体   繁体   中英

Why does Python platform.architecture() return the Windows Pre-Install Environment?

Seems like since Windows 10, the platform.architecture() function has been returning an erroneous value for the Windows Architecture. Shouldn't it identify AMD64? In any case PE is wrong.

From Microsoft :

Windows PE (WinPE) is a small operating system used to install, deploy, and repair Windows desktop editions, Windows Server, and other Windows operating systems.

When I start Python I get:

Python 3.7.9 (tags/v3.7.9:13c94747c7, Aug 17 2020, 18:58:18) [MSC v.1900 64 bit (AMD64)] on win32

Then I execute the following Python commands with the shown result.

import platform
platform.architecture()
('64bit', 'WindowsPE')

platform.architecture doesn't do what you think it does. It returns:

the bit architecture and the linkage format used for the executable . (emphasis mine)

ie the executable passed ( sys.executable , your python installation, by default) is 64-bit and is a Windows Portable Executable .

If you want the machine type you want platform.machine :

>>> import platform
>>> platform.machine()
'AMD64'

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM