mherrmann / fbs-tutorial

Tutorial for creating Python/Qt GUIs with fbs
https://build-system.fman.io
GNU General Public License v3.0
1.95k stars 161 forks source link

PySide2 example #18

Closed patrickelectric closed 5 years ago

patrickelectric commented 5 years ago

Is it possible to add an pyside2 example or add a reference of any pyside2 project that uses fbs ?

mherrmann commented 5 years ago

Good point. I've updated the tutorial:

You can also use Qt for Python instead of PyQt. To do this, simply write PySide2 instead of PyQt5 throughout this tutorial. For the above, use pip install PySide2 (without specifying a version).

You may also be interested in this PySide2 tutorial I wrote.

patrickelectric commented 5 years ago

Thank you, I was able to use fbs run, but freeze fails.

Traceback (most recent call last):
  File "/tmp/vv/bin/pyinstaller", line 11, in <module>
    sys.exit(run())
  File "/tmp/vv/lib/python3.7/site-packages/PyInstaller/__main__.py", line 111, in run
    run_build(pyi_config, spec_file, **vars(args))
  File "/tmp/vv/lib/python3.7/site-packages/PyInstaller/__main__.py", line 63, in run_build                                                                                         
    PyInstaller.building.build_main.main(pyi_config, spec_file, **kwargs)
  File "/tmp/vv/lib/python3.7/site-packages/PyInstaller/building/build_main.py", line 838, in main                                                                                  
    build(specfile, kw.get('distpath'), kw.get('workpath'), kw.get('clean_build'))
  File "/tmp/vv/lib/python3.7/site-packages/PyInstaller/building/build_main.py", line 784, in build                                                                                 
    exec(text, spec_namespace)
  File "<string>", line 17, in <module>
  File "/tmp/vv/lib/python3.7/site-packages/PyInstaller/building/build_main.py", line 241, in __init__                                                                              
    self.__postinit__()
  File "/tmp/vv/lib/python3.7/site-packages/PyInstaller/building/datastruct.py", line 158, in __postinit__                                                                          
    self.assemble()
  File "/tmp/vv/lib/python3.7/site-packages/PyInstaller/building/build_main.py", line 500, in assemble                                                                              
    module_hook.post_graph()
  File "/tmp/vv/lib/python3.7/site-packages/PyInstaller/building/imphook.py", line 410, in post_graph                                                                               
    self._load_hook_module()
  File "/tmp/vv/lib/python3.7/site-packages/PyInstaller/building/imphook.py", line 377, in _load_hook_module                                                                        
    self.hook_module_name, self.hook_filename)
  File "/tmp/vv/lib/python3.7/site-packages/PyInstaller/compat.py", line 736, in importlib_load_source                                                                              
    return mod_loader.load_module()
  File "<frozen importlib._bootstrap_external>", line 407, in _check_name_wrapper
  File "<frozen importlib._bootstrap_external>", line 907, in load_module
  File "<frozen importlib._bootstrap_external>", line 732, in load_module
  File "<frozen importlib._bootstrap>", line 265, in _load_module_shim
  File "<frozen importlib._bootstrap>", line 696, in _load
  File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 728, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/tmp/vv/lib/python3.7/site-packages/PyInstaller/hooks/hook-PySide2.QtQuick.py", line 13, in <module>                                                                        
    from PyInstaller.utils.hooks import get_qmake_path, exec_command
ImportError: cannot import name 'exec_command' from 'PyInstaller.utils.hooks' (/tmp/vv/lib/python3.7/site-packages/PyInstaller/utils/hooks/__init__.py)                             
Traceback (most recent call last):
  File "/usr/lib64/python3.7/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/usr/lib64/python3.7/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/tmp/vv/lib/python3.7/site-packages/fbs/__main__.py", line 36, in <module>
    main()
  File "/tmp/vv/lib/python3.7/site-packages/fbs/cmdline.py", line 26, in main
    args.fn(*fn_args)
  File "/tmp/vv/lib/python3.7/site-packages/fbs/builtin_commands/__init__.py", line 122, in freeze                                                                                  
    freeze_arch(debug=debug)
  File "/tmp/vv/lib/python3.7/site-packages/fbs/freeze/arch.py", line 4, in freeze_arch
    freeze_linux(extra_pyinstaller_args, debug)
  File "/tmp/vv/lib/python3.7/site-packages/fbs/freeze/linux.py", line 8, in freeze_linux
    run_pyinstaller(extra_pyinstaller_args, debug)
  File "/tmp/vv/lib/python3.7/site-packages/fbs/freeze/__init__.py", line 36, in run_pyinstaller                                                                                    
    run(args, check=True)
  File "/usr/lib64/python3.7/subprocess.py", line 481, in run
    output=stdout, stderr=stderr)
subprocess.CalledProcessError: Command '['pyinstaller', '--name', 'MyApp', '--noupx', '--log-level', 'ERROR', '--noconfirm', '--distpath', '/tmp/vv/target', '--specpath', '/tmp/vv/target/PyInstaller', '--workpath', '/tmp/vv/target/PyInstaller', '/tmp/vv/src/main/python/main.py']' returned non-zero exit status 1.  

It appears to be a problem with pyinstaller, related to this issue: https://github.com/pyinstaller/pyinstaller/issues/3689

mherrmann commented 5 years ago

Are you using Python 3.5 and PyInstaller 3.4?

patrickelectric commented 5 years ago

Python 3.7 and PyInstaller 3.4.

fredrikaverpil commented 5 years ago

I'm using the latest fbs with Python 3.7.1 and PyInstaller 3.4 without issues but I am primarily deploying on Windows and I am not using QtQuick.

For my particular PySide2 app, I need to make sure I have these hidden imports:

from PySide2 import QtXml
from PySide2 import QtUiTools

Judging by the error you posted, you might have to add QtQuick to your hidden imports.

patrickelectric commented 5 years ago

@fredrikaverpil thanks, but the problem is with pyinstaller. I'm developing under linux and doing some research with fbs and pyinstaller.

https://github.com/pyinstaller/pyinstaller/pull/3875 Does not fix everything but it's step closer to accomplish what I want.

@mherrmann With my last corrections with pyinstaller, I'm able to finish fbs freeze.

mherrmann commented 5 years ago

As mentioned in many places such as the tutorial, the Manual or the Troubleshooting page on fbs's web site, fbs only officially supports Python 3.5. I'm afraid I can't give help for 3.7 at this point.

patrickelectric commented 5 years ago

@mherrmann no problem, but is it possible to guide me if the problem is a consequence of fbs ? I would like to help and fix the issue.

 patrick@dell  /tmp/vv  python -m fbs freeze
VERSION> 5
qmake /bin/qmake
versionstring b'5.11.2'
QMAKE /usr/lib/qt/qml
ldd: warning: you do not have execution permission for `/usr/lib/libgcc_s.so.1'
Done. You can now run `target/MyApp/MyApp`. If that doesn't work, see
https://build-system.fman.io/troubleshooting.
 patrick@dell  /tmp/vv  ./target/MyApp/MyApp
Traceback (most recent call last):
  File "/mnt/hd/.local/lib/python3.7/site-packages/PyInstaller/loader/rthooks/pyi_rth_pkgres.py", line 11, in <module>                                                              
    import pkg_resources as res
  File "/home/patrick/.local/lib/python3.7/site-packages/PyInstaller/loader/pyimod03_importers.py", line 627, in exec_module                                                        
    exec(bytecode, module.__dict__)
  File "site-packages/pkg_resources/__init__.py", line 81, in <module>
ModuleNotFoundError: No module named 'packaging.specifiers'
[10069] Failed to execute script pyi_rth_pkgres

Any idea ?

patrickelectric commented 5 years ago

It appears to a problem with pyinstaller yet, I'll try to debug it more and update it here.

mherrmann commented 5 years ago

As I said, I'll re-join this discussion when you are using Python 3.5 :-) The Python and PyInstaller versions are strongly interdependent, and I don't have time to chase problems that may just be caused by a wrong Python version. (Or present itself differently on different Python versions.)

mherrmann commented 5 years ago

Not sure which Linux distribution you are on but I just tested again on Ubuntu and can follow the tutorial flawlessly with Python 3.5, PySide2 5.11.2 and PyInstaller 3.4.

patrickelectric commented 5 years ago

I'm using Arch. Try with 3.7 to see if you can replicate the issue.

On Fri, Nov 16, 2018, 2:06 PM Michael Herrmann <notifications@github.com wrote:

Not sure which Linux distribution you are on but I just tested again on Ubuntu and can follow the tutorial flawlessly with Python 3.5, PySide2 and PyInstaller 3.4.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/mherrmann/fbs-tutorial/issues/18#issuecomment-439441091, or mute the thread https://github.com/notifications/unsubscribe-auth/ABKMCfmYweq3nO_7Cx6_miVCRpVQ1NAiks5uvuJvgaJpZM4YkPTP .

mherrmann commented 5 years ago

I will not try with 3.7. As I said, at the moment I only support 3.5. I can tell you however that fman actually uses 3.6 on Arch, so you may have some luck there.