Converting py file to exe, Cannot find existing PyQt5 plugin directories

前端 未结 5 1990
余生分开走
余生分开走 2020-12-15 02:09

I\'m quite new to phyton and I\'ve just finished my first application. Now, I\'m trying to compile my .py file to an .exe buy that doestn seem to work. I\'ve looked everywhe

相关标签:
5条回答
  • 2020-12-15 02:24

    Try uninstalling Anaconda. There have been issues in the past. If not you can try py2exe that is fairly decent too.

    0 讨论(0)
  • 2020-12-15 02:26

    Conda 4.5.11, Python 3.6.4, PyInstaller 3.4

    The plugin path is determined incorrectly in hooks/qt.py. Qt requires that QCoreApplication is instantiated first, before any other calls.

    My qt.py hook is in ~\anaconda3\Lib\site-packages\PyInstaller\utils\hooks\qt.py.

    I edited it like so:

        json_str = exec_statement("""
            import sys
    
            # exec_statement only captures stdout. If there are
            # errors, capture them to stdout so they can be displayed to the
            # user. Do this early, in case PyQt5 imports produce stderr
            # output.
            sys.stderr = sys.stdout
    
            import json
            from %s.QtCore import QLibraryInfo, QCoreApplication
    
            # QLibraryInfo isn't always valid until a QCoreApplication is
            # instantiated.
            app = QCoreApplication([])
            paths = [x for x in dir(QLibraryInfo) if x.endswith('Path')]
            location = {x: QLibraryInfo.location(getattr(QLibraryInfo, x))
                        for x in paths}
            try:
                version = QLibraryInfo.version().segments()
            except AttributeError:
                version = None
            print(str(json.dumps({
                'isDebugBuild': QLibraryInfo.isDebugBuild(),
                'version': version,
                'location': location,
            })))
        """ % self.namespace)
    

    see 1.

    0 讨论(0)
  • 2020-12-15 02:31

    I installed the latest version of PyInstaller, then this exception of "Cannot find existing PyQt5 plugin directories" is addressed.

    You can install the latest version of PyInstaller through the following command:

    pip install https://github.com/pyinstaller/pyinstaller/tarball/develop
    

    P.S: Some information about my setup:

    $conda info
          conda version : 4.6.14
    conda-build version : 3.17.8
         python version : 3.7.3.final.0
               platform : win-64
             user-agent : conda/4.6.14 requests/2.21.0 CPython/3.7.3 Windows/10 Windows/10.0.17763
    
    $ pip show pyinstaller
    Name: PyInstaller
    Version: 3.5.dev0+d74052489
    Summary: PyInstaller bundles a Python application and all its dependencies into a single package.
    
    0 讨论(0)
  • I am using Python 3.6.3 with ANACONDA3 and Spyder as IDE. Pyinstaller 3.4.

    Trying to generate an exe file with Pyinstaller, I had two kinds of errors:

    1. "AttributeError: 'str' object has no attribute 'items' ". This was resolved by updating each module imported in the Python script, with : pip install --upgrade <module_name>
    2. "Cannot find existing PyQt5 plugin directories" :this was the next error. As mentioned by cong yu in his previous post, I fixed this problem by running pip install PyQt5

    3. Do not forget to upgrade setuptools to the latest version as well

    The process delivered an exe file which I have not yet tested. But at least, I got Pyinstaller reaching the end without failing in error.

    Hope this could be helpful

    And, by the way, Happy New Year :)

    Edit:

    I have tested the standalone .exe produced by py2exe The program is running and get to the end without errors.

    But the problem is that xlsx is no more running, because no Excel files are created. These files are based on pandas dataframes. My hint is that pandas module, which is the main core of the program, seems to be altered. I noticed that the dataframes used were truncated, through the control lines edited in the Ipython console in Spyder.

    I think that my best alternative is to reinstall Anaconda3.

    So be careful, upgrading the modules used in the program you want as standalone with py2exe. It seems that upgrading pandas module was a mistake.

    I am sorry, if I gave a bad advice in my main post, but upgrading was the best way to run py2exe. Be careful with the upgrade of pandas.

    0 讨论(0)
  • 2020-12-15 02:42

    Try the fix in Exception: Cannot find PyQt5 plugin directories when using Pyinstaller despite PyQt5 not even being used. In short:

    pip intall PyQt5

    Note that, strangely enough, conda install PyQt5 may not fix the problem.

    I encountered the same problem and saw another suggestion: make the missing directory (C:/qt5b/qt_1524647842210/_h_env/Library/plugins in your case) and copy the two files pyqt5.dll and pyqt5qmlplugin.dll (presumably somewhere in c:\Users[name]\AppData\Local\conda\conda\envs) to the directory.

    I did not try it since I fixed the problem with pip install PyQt5. You may want to give it a try.

    0 讨论(0)
提交回复
热议问题