[PyQt] pyqtdeploy build can't find modules
Phil Thompson
phil at riverbankcomputing.com
Sun Mar 27 18:24:05 BST 2016
On 19 Mar 2016, at 1:39 pm, David Beck <dbeck at ualberta.ca> wrote:
>
> Here you are. I’ve included both the regular one and the flat one.
>
> Appreciate the help.
>
> David
>
> <Test_projects.tar.gz>
>>>
>>> The second project is flat, with no .ui module:
>>>
>>> MiniBrowserflat
>>> __init__.py
>>> minibrowser.py
>>> mainwindow.py
>>> mainwindow.ui
>>> Ui_mainwindow.py
>>>
>>> When I try to build that, I get essentially the same thing:
>>>
>>> make succeeded.
>>> Running MiniBrowser...
>>> Running '/Users/David/OpenSource/PyQtDeploy/sysroot-macosx/build/MiniBrowser.app/Contents/MacOS/MiniBrowser'
>>> /Users/David/OpenSource/PyQtDeploy/sysroot-macosx/build/MiniBrowser.app/Contents/MacOS/MiniBrowser failed.
>>> Traceback (most recent call last):
>>> File "minibrowser.py", line 2, in <module>
>>> File "bootstrap.py", line 969, in _find_and_load
>>> File "bootstrap.py", line 956, in _find_and_load_unlocked
>>> ImportError: No module named ‘mainwindow'
>>>
>>> This seems to be caused, again, by an import command
>>>
>>> from mainwindow import MainWindow
>>>
>>> in the main script file.
I've only looked at the flat version.
The top-level package will be MiniBrowserflat - in a conventional installation this directory would be a sub-directory of site-packages. The main script (minibrowser.py) is not part of this package even though in this case it is in the same directory. Therefore the import statement in minibrowser.py should be...
from MiniBrowserflat.mainwindow import MainWindow
For the same reason the import in mainwindow.py should be...
from .Ui_mainwindow import Ui_MainWindow
This will deploy properly. However it will no longer run normally - unless you set PYTHONPATH. To get it to work unchanged in both circumstances move minibrowser.py to its parent directory so that it is side by side with the MiniBrowserflat directory.
Phil
More information about the PyQt
mailing list