Search code examples
pythonmacospyqt5beeware

Fail to package an app using Briefcase (BeeWare) and PyQt5


I have build a desktop application on macOS (macOS v13.4.1 (Ventura) - Intel processor) using Briefcase (BeeWare and PyQt5. It runs well when started with 'briefcase dev'.

However, when I tried to package it, it fails with the following error at the step 'briefcase run':

Enter image description here

Before starting, I have created a virtualenv using venv (python3 -m venv .venv)

And I started it. Everything that follows is within this .venv:

  1. created my application and it runs fine when I start it with 'briefcase dev':

    Enter image description here

  2. Typed 'briefcase create' (runs ok).

  3. Typed 'briefcase build' (runs ok).

  4. When trying to run the app: 'briefcase run' it fails with the error:

    ModuleNotFoundError: No module named 'PyQt5'

It seems like a pretty straightforward issue as the package is not found. I am suspecting that something with virtual env is not, right?


Solution

  • To simulate a user who's installed your app on their own machine, briefcase run does not run the app in your current virtual environment. Instead, it uses a separate environment which contains only the packages listed in your pyproject.toml file.

    So you'll have to add PyQT to the requires section of that file, and then run briefcase run -r to update the app's environment.

    For more details, see https://docs.beeware.org/en/latest/tutorial/tutorial-7.html.