0

Running same command directly in terminal returns a different output than running via subprocess.check_output. Anyone know what is causing this?

➜  /Users/okoo system_profiler SPHardwareDataType
Hardware:

    Hardware Overview:

      Model Name: MacBook Pro
      Model Identifier: MacBookPro17,1
      Chip: Apple M1
      Total Number of Cores: 8 (4 performance and 4 efficiency)
      Memory: 16 GB
      System Firmware Version: 7429.81.3
      OS Loader Version: 7429.81.3
      Serial Number (system): FVFGJ221Q05P
      Hardware UUID: 050F2C11-EA98-5EDB-A121-B66B0E810BAE
      Provisioning UDID: 00008103-000240323E79001E
      Activation Lock Status: Disabled

➜  /Users/okoo python3.9                         
Python 3.9.10 (main, Jan 15 2022, 11:48:00) 
[Clang 13.0.0 (clang-1300.0.29.3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import subprocess
>>> import os
>>> subprocess.check_output(["system_profiler", "SPHardwareDataType"], text=True, env=os.environ)
'Hardware:\n\n    Hardware Overview:\n\n      Model Name: MacBook Pro\n      Model Identifier: MacBookPro17,1\n      Processor Name: Unknown\n      Processor Speed: 2.4 GHz\n      Number of Processors: 1\n      Total Number of Cores: 8\n      L2 Cache: 8 MB\n      Memory: 16 GB\n      Serial Number (system): FVFGJ221Q05P\n      Hardware UUID: 050F2C11-EA98-5EDB-A121-B66B0E810BAE\n      Provisioning UDID: 050F2C11-EA98-5EDB-A121-B66B0E810BAE\n      Activation Lock Status: Disabled\n\n'

running in terminal result a line Chip: Apple M1

but this line is not present if running via subprocess, instead this line shows up Processor Name: Unknown

strange?

4

0 回答 0