You can use either multiprocessing or os module of Python to find the number of CPUs on a computer.
Here is an example:
>>> import multiprocessing>>> multiprocessing.cpu_count()8>>> import os>>> os.cpu_count()8>>>
>>> import multiprocessing
>>> multiprocessing.cpu_count()
8
>>> import os
>>> os.cpu_count()
>>>
The number shown above is the number of logical CPUs available on the system. If hyperthreading is enabled on your CPU, the count will also include virtual cores.