It work when i test,i use virtual environment always when troubleshoot Pyinstaller.
if not i would have gotten same error message as you get.
# Make G:\div_code λ python -m venv router_env # Cd in G:\div_code λ cd router_env\ # Activate G:\div_code\router_env λ G:\div_code\router_env\Scripts\activate.bat # Install (router_env) G:\div_code\router_env λ pip install pyinstaller RouterOS-api ..... Installing collected packages: pywin32-ctypes, altgraph, six, pyinstaller-hooks-contrib, pefile, RouterOS-api, pyinstaller Successfully installed RouterOS-api-0.17.0 altgraph-0.17.3 pefile-2023.2.7 pyinstaller-5.12.0 pyinstaller-hooks-contrib-2023.3 pywin32-ctypes-0.2.0 six-1.16.0Test code:
# router.py import routeros_api connection = routeros_api.RouterOsApiPool('IP', username='admin', password='') print(connection.username) input('Press Enter to exit')Build:
(router_env) G:\div_code\router_env λ pyinstaller --onefile route.py 500 INFO: PyInstaller: 5.12.0 500 INFO: Python: 3.11.3 572 INFO: Platform: Windows-10-10.0.19045-SP0 ..... 16020 INFO: Building EXE from EXE-00.toc completed successfully.When run
router.exe
it print admin,so it work and find module routeros_api
,if not i would have gotten same error message as you get.