[prev in list] [next in list] [prev in thread] [next in thread] 

List:       pykde
Subject:    [pyqtdeploy] ModuleNotFoundError after compilation
From:       Kristófer Reykjalín Þorláksson <kristofer () thorlaks
Date:       2020-06-27 12:48:34
Message-ID: d1323f6a-9228-d59e-df33-17006b773d97 () thorlaksson ! com
[Download RAW message or body]

I have a project with the following folder structure:

    project/
        __init__.py
        main.py
        ui/
            __init__.py
            mainwindow.py
            otherfile.py

The main.py file has the following import statement:

    from ui.mainwindow import MainWindow

When I run the project using `python main.py` it runs fine, but after
compiling via `pyqtdeploy` I get the following error when I run the
executable:

    ModuleNotFoundError: No module named 'ui'

After reading through one of the other threads on the mailing list [0] I
realized that I was able to successfully build and run the project by
changing the `mainwindow` import statement to:

    from project.ui.mainwindow import MainWindow

However, after making that change running `python main.py` no longer
works, because the path `project.ui.mainwindow` doesn't exist.

[0]:
http://python.6.x6.nabble.com/pyqtdeploy-build-can-t-find-modules-td5185029.html

I also tried a suggestion in the aforementioned thread and moved
`main.py` to be at the same level as `project` like so:

    __init__.py
    main.py
    project/
        __init__.py
        ui/
            __init__.py
            mainwindow.py
            otherfile.py

But that didn't work either; I could run the project using `python
main.py`, but got the same ModuleNotFoundError after buidling via
pyqtdeploy.


This isn't much more than an annoyance, but being forced to change the
import path before building the project is a _bit frustrating_.
Is it possible to have one import statement that works for both running
the project via `python main.py` and running the built executable that
does not including messing with path settings?


Best regards,
Kristófer R.
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic