Ultra-lightweight Python "** Python embeddable **". An ultra-lightweight Python execution environment of about 8MB for download compressed file .zip and about 16MB for decompression. I was able to confirm how to prepare the execution environment, so make a note of it.
https://www.python.org/downloads/windows/ ↓ https://www.python.org/downloads/release/python-391/ Download the Windows embeddable package (64-bit). ↓ python-3.9.1-embed-amd64.zip ↓ When expanded, the folder "python-3.9.1-embed-amd64" will contain Mostly composed of .pyd (contents are DLL) and .dll files. ↓ When you start "python.exe" inside, the interactive console is displayed.
import datetime
datetime.datetime.now()
x = 2**32
x
↓ Download destination: Download "get-pip.py" from https://bootstrap.pypa.io/get-pip.py, save it in the folder "python-3.9.1-embed-amd64", and "get-pip" Drag and drop ".py" onto "python.exe" (or DOS command: python.exe get-pip.py) and execute. "Pip" is available. ↓ Open the file "python39._pth" with a text editor and uncomment "#import site" "import site" ↓ For example, if you install the library "psutil" that obtains information such as CPU and memory usage, you can use "DOS command: python.exe -m pip install psutil". ↓ Installation is complete. ↓ When I try to use the library "psutil", CPU usage rate and memory usage rate are acquired and OK.
import psutil
psutil.cpu_percent()
psutil.virtual_memory()
↓ When the library "psutil" is installed, the execution environment is about 34MB.
https://qiita.com/mm_sys/items/1fd3a50a930dac3db299 https://qiita.com/suzuki_y/items/3261ffa9b67410803443 https://pypi.org/project/psutil/
Recommended Posts