whaleygeek / bitio

A micro:bit I/O device library for Python
Other
92 stars 31 forks source link

bitio has problems when bundled into a single executable using pyinstaller #22

Open ukscone opened 6 years ago

ukscone commented 6 years ago

when using pyinstaller to turn a bitio based program into a single executable with no other pyinstaller options than -F (single file) e.g.

pyinstaller -F my_script.py

pyinstaller uses the system pyserial e.g. warning:I got the system installed pyserial, that was unexpected if pyinstaller is used with the -p option to add the abs path of the microbit module then it uses the microbit supplied serialmodule but then it fails for REPL e.g. Traceback (most recent call last): File "scan-n-go-ini.py", line 30, in <module> import microbit File "<frozen importlib._bootstrap>", line 2237, in _find_and_load File "<frozen importlib._bootstrap>", line 2226, in _find_and_load_unlocked File "<frozen importlib._bootstrap>", line 1200, in _load_unlocked File "<frozen importlib._bootstrap>", line 1129, in _exec File "c:\python34\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 631, in exec_module exec(bytecode, module.__dict__) File "microbit\__init__.py", line 127, in <module> repl = repl.REPL(s) AttributeError: 'module' object has no attribute 'REPL' [5024] Failed to execute script scan-n-go-ini

ukscone commented 6 years ago

changing the import line from import serial

to from . import serial

seems to fix it although probably not the "right" way to do it