[PyQt] pyqtdeploy build can't find modules

David Beck dbeck at ualberta.ca
Thu Mar 17 20:08:43 GMT 2016


> On Mar 12, 2016, at 7:40 AM, Phil Thompson <phil at riverbankcomputing.com> wrote:
> 
> On 11 Mar 2016, at 6:06 pm, David Beck <dbeck at ualberta.ca> wrote:
>> 
>> I added an __init__.py to the ELFB directory and get the same results. I will try making a completely “flat” version of my project to see if it can be deployed that way (but it makes project management just that little bit messier).

Further to this aspect of the problem, I experimented by building two very simple projects using Eric, both of which run fine in Eric and with the Python 3.5 IDLE. The first one mimics the structure of the ELFB project, which has the directory structure

MiniBrowser
	__init__.py
	minibrowser.py
	ui
		__init__.py
		mainwindow.py
		mainwindow.ui
		Ui_mainwindow.py

When I deploy it, I get the same “ImportError: No module named ‘ui’” that I reported earlier. 

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 944, in _find_and_load_unlocked
  File "bootstrap.py", line 222, in _call_with_frames_removed
  File "bootstrap.py", line 969, in _find_and_load
  File "bootstrap.py", line 956, in _find_and_load_unlocked
ImportError: No module named 'ui'

This error seems to be triggered by the line 

	from ui.mainwindow import MainWindow 

in the minibrowser.py main script file.

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.

So whatever is going on, it’s not particular to the project I was working on. The deployed app just doesn’t seem to be able to look inside of modules.

David


>> 
>> As you suggested, I cloned the Mercurial repository for PyQtDeploy and deployed pyqtdeploy.app successfully. If I try deploy my ELFB.pdy file, I get the output:
>> 
>> Generating code...
>> Creating directory /Users/David/OpenSource/PyQtDeploy/sysroot-macosx/build
>> Creating directory /Users/David/OpenSource/PyQtDeploy/sysroot-macosx/build/resources
>> Creating directory /Users/David/OpenSource/PyQtDeploy/sysroot-macosx/build/resources/eFieldBook_Qt5
>> Creating directory /Users/David/OpenSource/PyQtDeploy/sysroot-macosx/build/resources/eFieldBook_Qt5/palettes
>> Creating directory /Users/David/OpenSource/PyQtDeploy/sysroot-macosx/build/resources/eFieldBook_Qt5/ui
>> Creating directory /Users/David/OpenSource/PyQtDeploy/sysroot-macosx/build/resources/eFieldBook_Qt5/ui/rsrc
>> Creating directory /Users/David/OpenSource/PyQtDeploy/sysroot-macosx/build/resources/collections
>> Creating directory /Users/David/OpenSource/PyQtDeploy/sysroot-macosx/build/resources/encodings
>> Creating directory /Users/David/OpenSource/PyQtDeploy/sysroot-macosx/build/resources/importlib
>> Creating directory /Users/David/OpenSource/PyQtDeploy/sysroot-macosx/build/resources/PyQt5
>> Running 'python3.5 -OO /var/folders/xc/l59x44tx4_bbl7d78cp44fyc0000gn/T/pyqtdeploy-hwtH42/freeze.py /var/folders/xc/l59x44tx4_bbl7d78cp44fyc0000gn/T/pyqtdeploy-hwtH42/jobs.csv'
>> Unable to freeze files
>> No such file or directory
>> 
>> I looked and there is no /pyqtdeploy-hwtH42/freeze.py or jobs.csv at that location. Neither were requested when I was deploying pyqtdeploy.pdy. I don’t know if that is related to my original problem, but it might have something to do with how the Mercurial pyqtdeploy was deployed.
> 
> freeze.py and jobs.csv are created in a temporary directory that is deleted by the time the program terminates. If you edit builder.py and add...
> 
>    temp_dir.setAutoRemove(False)
> 
> ...below the line that creates the QTemporaryDir instance then the directory and its contents should survive. You can then run the freeze.py script manually to see what's going on.
> 
> Phil



More information about the PyQt mailing list