Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pyinstaller issue. #2298

Closed
dillonvuong opened this issue May 10, 2022 · 13 comments
Closed

Pyinstaller issue. #2298

dillonvuong opened this issue May 10, 2022 · 13 comments
Labels
freeze Issues pertaining to packaging tools such as pyinstaller, cx_freeze and nuitka

Comments

@dillonvuong
Copy link

dillonvuong commented May 10, 2022

Hi I have the module not found error like others [2179] with pyinstaller. I could not figure out the answer from the other threads so I am making a new one.

Here is my issue:
image

I use the following spec file to create the pyqtgraph:

`# -*- mode: python ; coding: utf-8 -*-
from PyInstaller.utils.hooks import collect_data_files
import os
import site

ROOT_PATH = os.getcwd()
PACKAGE_SITE= site.getusersitepackages()

print(ROOT_PATH)
print(PACKAGE_SITE)

datas = [(f'{ROOT_PATH}/config', './config'), (f'{ROOT_PATH}/assets', './assets'), (f'{ROOT_PATH}/log', './log')]
datas += collect_data_files('qt_material')

block_cipher = None


a = Analysis([f'{ ROOT_PATH }/main.py'],
             pathex=[ROOT_PATH, r"C:\Users\Beast\AppData\Roaming\Python\Python38\site-packages\pyqtgraph\graphicsItems\ViewBox\axisCtrlTemplate_pyside2.py"],
             binaries=[],
             datas=datas,
             hiddenimports=[],
             hookspath=[f'{PACKAGE_SITE}/pyupdater/hooks'],
             hooksconfig={},
             runtime_hooks=[],
             excludes=[],
             win_no_prefer_redirects=False,
             win_private_assemblies=False,
             cipher=block_cipher,
             noarchive=False)
pyz = PYZ(a.pure, a.zipped_data,
             cipher=block_cipher)

exe = EXE(pyz,
          a.scripts,
          [],
          exclude_binaries=True,
          name='win',
          debug=False,
          bootloader_ignore_signals=False,
          strip=False,
          upx=True,
          console=True,
          disable_windowed_traceback=False,
          target_arch=None,
          codesign_identity=None,
          embed_manifest=False,
          entitlements_file=None )
coll = COLLECT(exe,
               a.binaries,
               a.zipfiles,
               a.datas,
               strip=False,
               upx=True,
               upx_exclude=[],
               name='win')`
@j9ac9k j9ac9k added the freeze Issues pertaining to packaging tools such as pyinstaller, cx_freeze and nuitka label May 10, 2022
@j9ac9k
Copy link
Member

j9ac9k commented May 10, 2022

Hi @dillonvuong

I updated your post to have syntax highlighting for the spec file.

Can you provide the output of pip list please?

EDIT: I think the you may need to put the template files in the hiddenimports section, as well, but the pyinstaller-hooks package should handle that for you if you have an up to date version of it.

@dillonvuong
Copy link
Author

dillonvuong commented May 10, 2022

@j9ac9k Thank you! Here is my pip list. My pyinstaller-hooks package is version 2022.3 which is like this ticket #2234

Package                   Version
------------------------- ---------
altgraph                  0.17.2
appdirs                   1.4.4
attrs                     21.4.0
Automat                   20.2.0
boto3                     1.21.35
botocore                  1.24.35
bsdiff4                   1.2.2
certifi                   2021.10.8
cffi                      1.15.0
chardet                   4.0.0
constantly                15.1.0
cycler                    0.10.0
dsdev-utils               1.0.5
event-bus                 1.0.2
future                    0.18.2
hyperlink                 21.0.0
idna                      3.3
incremental               21.3.0
Jinja2                    2.11.3
jmespath                  1.0.0
joblib                    1.0.1
kiwisolver                1.3.1
MarkupSafe                1.1.1
mat4py                    0.5.0
matplotlib                3.3.4
mpv                       0.1
nidaqmx                   0.5.7
numpy                     1.20.1
pandas                    1.2.3
pbr                       5.8.1
pefile                    2021.9.3
Pillow                    8.1.0
pip                       22.0.4
shiboken2                 5.15.2
shiboken6                 6.0.1
six                       1.15.0
spinnaker-python          2.3.0.77
stevedore                 3.5.0
threadpoolctl             2.1.0
Twisted                   22.2.0
twisted-iocpsupport       1.0.2
typing_extensions         4.1.1
urllib3                   1.26.9
wheel                     0.37.1
zope.interface            5.4.0

@dillonvuong
Copy link
Author

Oh also this is how I build the exe:
pyupdater build --app='v0.0.1' .pyupdater/spec/win.spec

@j9ac9k
Copy link
Member

j9ac9k commented May 10, 2022

Hi @dillonvuong this is a confusing environment.

It's not showing pyqtgraph installed. I see shiboken2 and shiboken6 but no pyside bindings (or any Qt bindings for that matter). Also not seeing pyinstaller or pyinstaller-hooks. Is this a conda environment by chance?

@dillonvuong
Copy link
Author

dillonvuong commented May 10, 2022

Ah sorry, I am using a venv with PyCharm.

Edit: actually here is my pip3 list which is more relevant

Package                   Version
------------------------- ---------
altgraph                  0.17.2   
appdirs                   1.4.4    
attrs                     21.4.0   
Automat                   20.2.0   
boto3                     1.21.35  
botocore                  1.24.35  
bsdiff4                   1.2.2    
certifi                   2021.10.8
cffi                      1.15.0   
chardet                   4.0.0    
constantly                15.1.0   
cycler                    0.10.0   
dsdev-utils               1.0.5    
event-bus                 1.0.2    
future                    0.18.2   
hyperlink                 21.0.0   
idna                      3.3      
incremental               21.3.0   
Jinja2                    2.11.3   
jmespath                  1.0.0    
joblib                    1.0.1    
kiwisolver                1.3.1
MarkupSafe                1.1.1
mat4py                    0.5.0
matplotlib                3.3.4
mpv                       0.1
nidaqmx                   0.5.7
numpy                     1.20.1
pandas                    1.2.3
pbr                       5.8.1
pefile                    2021.9.3
Pillow                    8.1.0
pip                       22.0.4
pycparser                 2.21
pyinstaller               4.8
pyinstaller-hooks-contrib 2022.3
pymodbus                  2.5.3
pymodbus3                 1.0.0
PyNaCl                    1.5.0
pyparsing                 2.4.7
PyQt5-sip                 12.8.1
PyQt5-stubs               5.14.2.2
pyqtgraph                 0.12.4
pyserial                  3.5
PySide2                   5.15.2
python-dateutil           2.8.1
python-mpv                0.5.2
pytz                      2021.1
PyUpdater                 4.0
PyUpdater-S3-Plugin       4.1.2
pywin32-ctypes            0.2.0
PyYAML                    6.0
qt-material               2.8.4
qtwidgets                 0.18
s3transfer                0.5.2
scikit-learn              0.24.1
scipy                     1.6.1
sentry-sdk                1.5.8
setuptools                60.2.0
shiboken2                 5.15.2
shiboken6                 6.0.1
six                       1.15.0
spinnaker-python          2.3.0.77
stevedore                 3.5.0
threadpoolctl             2.1.0
Twisted                   22.2.0
twisted-iocpsupport       1.0.2
typing_extensions         4.1.1
urllib3                   1.26.9
wheel                     0.37.1
zope.interface            5.4.0

@j9ac9k
Copy link
Member

j9ac9k commented May 10, 2022

ahh yes, I keep forgetting on windows there is often a benefit with doing python -m pip not just pip. Still, this environment has a number of issues; both PySide2 and PyQt5 bindings are installed and shiboken6 is installed indicating you likely had PySide6 installed at some point, but no longer do. I don't think any of this is a deal breaker on its own, but I think you would benefit from creating a new virtual environment with just the dependencies you need to package with pyinstaller.

Is the application you're attempting to freeze have a requirements.txt you can recreate the environment from?

@dillonvuong
Copy link
Author

Yes this is the requirements.txt and from what I understand it was created a while back with pip3 freeze? It might be outdated. How may I go about recreating a correct environment?

cycler==0.10.0
event-bus==1.0.2
Jinja2==2.11.3
joblib==1.0.1
kiwisolver==1.3.1
MarkupSafe==1.1.1
matplotlib==3.3.4
mpv==0.1
numpy==1.20.1
pandas==1.2.3
Pillow==8.1.0
pyinstaller~=4.3
pymodbus~=2.5.1
pyparsing==2.4.7
PyQt5-sip==12.8.1
PyQt5-stubs==5.14.2.2
pyqtgraph~=0.12.1
pyserial==3.5
PySide2==5.15.2
python-dateutil==2.8.1
python-mpv==0.5.2
pytz==2021.1
qt-material==2.8.4
qtwidgets==0.18
scikit-learn==0.24.1
scipy==1.6.1
shiboken2==5.15.2
shiboken6==6.0.1
six==1.15.0
threadpoolctl==2.1.0
pymodbus3~=1.0.0
pyyaml
pyupdater~=4.0
pyupdater-s3-plugin~=4.1.2
dsdev-utils==1.0.5
sentry-sdk~=1.5.7
nidaqmx
mat4py

./spinnaker_python-2.3.0.77-cp38-cp38-win_amd64.whl

@j9ac9k
Copy link
Member

j9ac9k commented May 10, 2022

ahh yeah, this does appear to have been created with pip freeze as it seems to have just dumped everything in the environment into the requirements.txt file. In terms of recreating the correct environment, that's a bit tough to do if your requirements.txt is just the output of pip freeze, so hard for me to say if it's "correct", the environment is as described it would appear.

If I was the one debugging this, I would create a new virtual environment with the python version I want to use, and try running that application from source, and install dependencies one at a time until the application runs successfully.

If you're also feeling adventurous; you can try installing pyqtgraph based on this current draft PR, and see if that fixes your issue

python -m pip uninstall pyqtgraph
python -m pip install git~https://github.com/pijyoi/pyqtgraph.git@generic_template

This installs pyqtgraph in the form of PR #2226, which @pijyoi was kind enough to submit (which seeks to do away w/ those template files).

@dillonvuong
Copy link
Author

dillonvuong commented May 10, 2022

@j9ac9k I did as you said and deleted my venv folder and made a new virtual environment. I installed packages one by one until the app ran. This fixed the problem for me. I am wondering why this is? Thank you for helping me!

@dillonvuong
Copy link
Author

Oh also I had this warning. I am a little concerned but the app runs fine and the pyqtgraph shows correctly.

Failed to collect submodules for 'pyqtgraph.canvas' because importing 'pyqtgraph.canvas' raised: ModuleNotFoundError: No module named 'CanvasManager'

@j9ac9k
Copy link
Member

j9ac9k commented May 13, 2022

Thanks for the heads up on the canvas warning, should be harmless, that's not a portion of the library that is currently used very much (at all?).

In terms of "why" it started working, I'm not a great person to ask for this. PyInstaller as far as I'm concerned works off of magic. The task it does is hugely complex; and while I have used it plenty for my own work, I have used it enough to be very careful about how I do use it, as it's fairly sensitive. Part of being careful with pyinstaller is not asking it to do any more than absolutely necessary, which means keeping dependencies to only what is strictly needed, and no more. Of course, that doesn't answer the question of why was the error a pyqtgraph one, and to that effect I suspect there is likely something we could do, but the only thing I can think of doing is already done here: https://github.com/pyinstaller/pyinstaller-hooks-contrib/blob/master/src/_pyinstaller_hooks_contrib/hooks/stdhooks/hook-pyqtgraph.py

Sorry I don't have a better answer for you. Only thing I can say is if during your packaging you do come across the root cause of that issue, we would love to know about it!

@pbmanis
Copy link
Contributor

pbmanis commented Aug 20, 2022

@j9ac9k: Just FYI the canvas module is used in acq4 (www.acq4.org), somewhat extensively.

@j9ac9k
Copy link
Member

j9ac9k commented Aug 20, 2022 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
freeze Issues pertaining to packaging tools such as pyinstaller, cx_freeze and nuitka
Projects
None yet
Development

No branches or pull requests

3 participants