Get CPU count from Python
Python psutil allows accessing numerous aspects of system parameters, including CPU count. We recommend using a recent version of PSutil to cover more computing platforms.
Ncpu = psutil.cpu_count(logical=False)
usually gives the physical CPU count.
PSutil uses Python script and compiled C code to determine CPU count–it’s not just a simple Python script.
Related: Matlab CPU count