Coder Social home page Coder Social logo

PySide2 example about fbs-tutorial HOT 13 CLOSED

mherrmann avatar mherrmann commented on July 2, 2024
PySide2 example

from fbs-tutorial.

Comments (13)

mherrmann avatar mherrmann commented on July 2, 2024

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.

from fbs-tutorial.

patrickelectric avatar patrickelectric commented on July 2, 2024

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: pyinstaller/pyinstaller#3689

from fbs-tutorial.

mherrmann avatar mherrmann commented on July 2, 2024

Are you using Python 3.5 and PyInstaller 3.4?

from fbs-tutorial.

patrickelectric avatar patrickelectric commented on July 2, 2024

Python 3.7 and PyInstaller 3.4.

from fbs-tutorial.

fredrikaverpil avatar fredrikaverpil commented on July 2, 2024

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.

from fbs-tutorial.

patrickelectric avatar patrickelectric commented on July 2, 2024

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

pyinstaller/pyinstaller#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.

from fbs-tutorial.

mherrmann avatar mherrmann commented on July 2, 2024

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.

from fbs-tutorial.

patrickelectric avatar patrickelectric commented on July 2, 2024

@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 ?

from fbs-tutorial.

patrickelectric avatar patrickelectric commented on July 2, 2024

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

from fbs-tutorial.

mherrmann avatar mherrmann commented on July 2, 2024

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.)

from fbs-tutorial.

mherrmann avatar mherrmann commented on July 2, 2024

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.

from fbs-tutorial.

patrickelectric avatar patrickelectric commented on July 2, 2024

from fbs-tutorial.

mherrmann avatar mherrmann commented on July 2, 2024

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.

from fbs-tutorial.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.