1

I have build a python script which uses MySQLDB. I am able to run the code locally and everything works fine but when after building the executable using pyinstaller and running it, I am getting this error No module named _mysql Line 19 in path MySQLDb/__init.py

Please help.

skr
  • 2,146
  • 19
  • 22
nitinvijay23
  • 1,781
  • 3
  • 13
  • 11
  • https://github.com/pyinstaller/pyinstaller/issues/323 – Charles Duffy Aug 18 '17 at 15:39
  • If you explicitly `import _mysql` and `import _mysql_exceptions` -- either directly or via a hook -- that'll resolve it. – Charles Duffy Aug 18 '17 at 15:40
  • Also closely related: https://stackoverflow.com/questions/7436132/pyinstaller-spec-file-importerror-no-module-named-blah – Charles Duffy Aug 18 '17 at 15:40
  • While building I see this : hidden import _mysql not found – nitinvijay23 Aug 19 '17 at 01:48
  • I have tried all possible solutions but nothing worked. – nitinvijay23 Aug 19 '17 at 02:05
  • How to import module via a hook? – nitinvijay23 Aug 19 '17 at 02:08
  • So it *is* looking for it at build time? Then you need to find out why it's not finding it. Too many possibilities to be able to speculate here -- maybe the C library was built for a different interpreter, for example; the Python bits will port straight across, the C parts not so much. Make sure it's the same Python install (same virtualenv, etc) with pyinstaller that you're also successfully testing with at dev time. – Charles Duffy Aug 19 '17 at 03:49

0 Answers0