marcelotduarte / cx_Freeze

cx_Freeze creates standalone executables from Python scripts, with the same performance, is cross-platform and should work on any platform that Python itself works on.
https://marcelotduarte.github.io/cx_Freeze/
Other
1.36k stars 220 forks source link

Problems running pyqt tutorial on cx_freeze 7.2.4 #2676

Open GabrielMarcilio opened 4 days ago

GabrielMarcilio commented 4 days ago

Sorry if this is not the correct place to ask for it. I believe that the pyqt sample is outdated/missing some steps

I can run the pyqt sample application (test_pyqt.py) in dev mode and run the created binary correctly when using cx_freeze 6.15.12 and pyqt 5.15.9

However if i use cx_freeze 7.2.4 and the same pyqt, when i run the created binary the application crashes when loading pyqt:

import_pyqt_error

The only change that i made from cx_freeze 6,15,12 to 7.2.4 was in setup.py file the executable base changed from "Win32GUI" to "gui".

Can you please confirm that the pyqt sample works with cx_freeze 7.2.4?

Thanks

marcelotduarte commented 3 days ago

Yes, it works for me. I just tested it now.

GabrielMarcilio commented 2 days ago

Thanks for the quick response Marcelo. Can you confirm the pyqt version that you used?

I am using a conda environment here with: conda create --name test_qt python=3.10.4 cx_freeze=7.2.5 pyqt=5.15.9

marcelotduarte commented 2 days ago

I always use the latest packages to test. conda list

  Python 3.10.15 | packaged by conda-forge | (main, Oct 16 2024, 01:15:49) [MSC v.1941 64 bit (AMD64)]

  # packages in environment at C:\Miniconda\envs\windows-latest-3.10:
  #
  # Name                    Version                   Build  Channel
  bzip2                     1.0.8                h2466b09_7    conda-forge
  ca-certificates           2024.8.30            h56e8100_0    conda-forge
  cabarchive                0.2.4              pyhd8ed1ab_0    conda-forge
  cx_freeze                 7.2.5           py310ha8f682b_0    conda-forge
  cx_logging                3.2.1           py310ha8f682b_0    conda-forge
  filelock                  3.16.1             pyhd8ed1ab_0    conda-forge
  glib                      2.82.2               h7025463_0    conda-forge
  glib-tools                2.82.2               h4394cf3_0    conda-forge
  gst-plugins-base          1.24.7               hb0a98b8_0    conda-forge
  gstreamer                 1.24.7               h5006eae_0    conda-forge
  icu                       75.1                 he0c23c2_0    conda-forge
  krb5                      1.21.3               hdf4eb48_0    conda-forge
  libclang13                19.1.3          default_ha5278ca_0    conda-forge
  libffi                    3.4.2                h8ffe710_5    conda-forge
  libglib                   2.82.2               h7025463_0    conda-forge
  libiconv                  1.17                 hcfcfb64_2    conda-forge
  libintl                   0.22.5               h5728263_3    conda-forge
  libintl-devel             0.22.5               h5728263_3    conda-forge
  libjpeg-turbo             3.0.0                hcfcfb64_1    conda-forge
  liblief                   0.14.1               he0c23c2_2    conda-forge
  libogg                    1.3.5                h2466b09_0    conda-forge
  libpng                    1.6.44               h3ca93ac_0    conda-forge
  libsqlite                 3.47.0               h2466b09_1    conda-forge
  libvorbis                 1.3.7                h0e60522_0    conda-forge
  libzlib                   1.3.1                h2466b09_2    conda-forge
  openssl                   3.4.0                h2466b09_0    conda-forge
  packaging                 24.1               pyhd8ed1ab_0    conda-forge
  pcre2                     10.44                h3d7b363_2    conda-forge
  pip                       24.3.1             pyh8b19718_0    conda-forge
  ply                       3.11               pyhd8ed1ab_2    conda-forge
  py-lief                   0.14.1          py310h9e98ed7_2    conda-forge
  pyqt                      5.15.9          py310h1fd54f2_5    conda-forge
  pyqt5-sip                 12.12.2         py310h00ffb61_5    conda-forge
  python                    3.10.15         hfaddaf0_2_cpython    conda-forge
  python_abi                3.10                    5_cp310    conda-forge
  qt-main                   5.15.15              h264fbc2_0    conda-forge
  setuptools                75.3.0             pyhd8ed1ab_0    conda-forge
  sip                       6.7.12          py310h00ffb61_0    conda-forge
  striprtf                  0.0.27             pyhd8ed1ab_0    conda-forge
  tk                        8.6.13               h5226925_1    conda-forge
  toml                      0.10.2             pyhd8ed1ab_0    conda-forge
  tomli                     2.1.0              pyhff2d567_0    conda-forge
  tzdata                    2024b                hc8b5060_0    conda-forge
  ucrt                      10.0.22621.0         h57928b3_1    conda-forge
  vc                        14.3                h8a93ad2_22    conda-forge
  vc14_runtime              14.40.33810         hcc2c482_22    conda-forge
  vs2015_runtime            14.40.33810         h3bf8584_22    conda-forge
  wheel                     0.45.0             pyhd8ed1ab_0    conda-forge
  xz                        5.2.6                h8d14728_0    conda-forge
  zstd                      1.5.6                h0ea2cb4_0    conda-forge
GabrielMarcilio commented 1 day ago

Hi Marcelo, i might be missing something here, hope you can give me some light:

When i create a conda env with only python, and then use pip to install cx_freeze and qt, the tutorial works fine When i create a conda env with python, cx_freeze and qt the tutorial crashes when loading QtCore.

I compared the the environment variable PATH on both created executables:

import os python_path = os.environ['PATH']

And it called my attention that the binary created from pip package contains the folders:

\lib\PyQt5\Qt5\bin #<- Qt5Core.dll is located here \lib

While the binary created using conda package only contains the lib folder (it does not contains the bin folder where the Qt5Core is located)

\lib

(I am omitting other folders that are present in both binaries.) I copied the contents from \lib\PyQt5\Qt5\bin into \lib, and then the binary created from conda package worked.

Do you have any idea why the paths are different when qt is created from pip or conda packages?

marcelotduarte commented 1 day ago

PyQt5 installed from pip has the modules an libraries in the same directory (libraries is in the PyQt5/lib) while the conda installation the directory structure is different. You can use an environment variable to check this. In windows command line set QT_DEBUG=1 that cx_Freeze will print it to you.