I want to compile my python code to binary by using pyinstaller
, but the hidden import
block me. For example, the following code import psutil
and print the CPU count:
# example.py
import psutil
print psutil.cpu_count()
And I compile the code:
$ pyinstaller -F example.py --hidden-import=psutil
When I run the output under dist
:
ImportError: cannot import name _psutil_linux
Then I tried:
$ pyinstaller -F example.py --hidden-import=_psutil_linux
Still the same error. I have read the pyinstall manual, but I still don't know how to use the hidden import
. Is there a detailed example for this? Or at least a example to compile and run my example.py
?
ENVs:
- OS: Ubuntu 14.04
- Python: 2.7.6
- pyinstaller: 2.1