How to create a hook module for PyInstaller?

I recently created a script using PyQt and several other packages that I would like to distribute to other people, and I tried to load it into exe using PyInstaller.

The problem I am facing is that the β€œFailed import, not find find” I am collecting is due to the fact that I need to create hook files for some modules. I tried following the limited tutorial in the PyInstaller manual, but it doesn't seem to work the way I tried. Any ideas? The generated .exe file failed with an error from the step "from import obspy.core import *", therefore it is assumed that the import occurred before it went through a fine.

My imports for the script are as follows:

import os.path import sys import string import fnmatch import numpy as np from PyQt4.QtCore import * from PyQt4.QtGui import * from obspy.core import read from matplotlib.figure import Figure from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg as FigureCanvas from matplotlib.backends.backend_qt4agg import NavigationToolbar2QTAgg as NavigationToolbar from matplotlib.widgets import MultiCursor from obspy.signal import rotate from obspy.signal import filter 
+4
source share
1 answer

Rule # 1 is that the python script cannot have the same name as the module (i.e. mail.py will cause problems with importing the module named "mail"). My guess is, maybe you have a script name obspy.py or a .pyc file with that name.

As for my import setup for custom module, this is what works for me.

Create a module named Foo with widgets called Bar. In a file named Foo / __ init__.py, list the modules to import:

 import Bar 

Then in the script:

 From Foo import Bar 

print Bar.helloworld

0
source

All Articles