Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Import serial breaks Python executable built with Nuitka #63

Closed
morefigs opened this issue Jan 10, 2016 · 2 comments
Closed

Import serial breaks Python executable built with Nuitka #63

morefigs opened this issue Jan 10, 2016 · 2 comments

Comments

@morefigs
Copy link

I'm attempting to build a very simple Python standalone executable using Nuitka:

import serial
print 'hello'

Building the executable using nuitka --standalone --portable app.py works, but if the PC's C:\Python27 directory is missing then the program fails with:

Traceback (most recent call last):
  File "C:\app\app.dist\app.py", line 6, in <module>
  File "C:\app\app.dist\serial\__init__.py", line 26, in serial

  File "C:\app\app.dist\serial\serialwin32.py", line 12, in serialwin32
  File "C:\Python27\lib\ctypes\__init__.py", line 10, in <module>

ImportError: No module named _ctypes

I suppose technically this is an issue with Nuitka not properly finding dependencies (I will post there too), but many other modules do work. I haven't checked yet if serial/ctypes does some sort of tricky importing.

In the meantime the workaround on the pyserial side is to simply add import _ctypes at the top of serialwin32.py. If it helps I can make a pull request for this.

@morefigs morefigs changed the title ImportError for _ctypes module after building standalone executable with Nuitka Import serial breaks Python executable built with Nuitka Jan 11, 2016
@zsquareplusc
Copy link
Member

pySerial uses ctypes with no tricks, there is only one not so common thing in __init__.py where the different platforms are imported, these are selected by an if. So far i have not have any problems packaging apps e.g. with py2exe.

I would not like to add to add the proposed "magic" import line in pySerial, it would be an import that is not used anywhere which gives minus points on the PEP-8 scoreboard ;-) Maybe you can add that import to your application or find out why Nuitka does not pick up the dependencies in this case (maybe because os.name == 'nt' is not true while it scans the sources?).

@morefigs
Copy link
Author

Yes fair enough, if there's nothing tricky going on then this isn't really a problem with pyserial so agreed it's not ideal to address it here. (=

It's trivial to add the workaround to the application file, but I've also but a bug report in with Nuitka.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants