From: Thomas H. <th...@ct...> - 2014-10-16 18:09:12
|
Am 04.10.2014 um 01:23 schrieb William Ferreira: > Goodnight everyone > > I'm trying to compile a simple script that uses PySide[1] into an > executable with py2exe with the following script[2]. Everything works > normal, the generated executable in the "dist" folder along with any > files needed: [...] > However I would like to generate an executable with .pyd packaged along > with the exe, as is done in DropBox and Ninja IDE. For this it is > necessary to change ** ** bundle_files option for other values, where > two packages the .pyd, the first .pyd and pythonXX.dll or 0 (zero) that > wraps all dll and .pyd. > > Making the change to any of these values py2exe issues a warning that > should have used the option 3. Removing this restriction (method > hook_PySide in hooks.py) rushes the process usually put the runs does > not application issuing the error "zipimport.ZipImportError: can't find > module PySide" Well, there are several problems that cause the behaviour that you describe above. First, I added the hook_PySide() method in hooks.py because I noticed that pyside programs only work with bundle_files == 3. This function can probably be removed. Second, please replace line 87 in Lib/site-packages/zipextimporter.py (which is part of py2exe): " except Exception:" by this code: " except ImportError:". This code did hide the real problem with PySide. When you now build an exe from a simple pyside script (with bundle_files set t0 0, 1, or 2), you get this when you start the exe: Traceback (most recent call last): File "test_pyside.py", line 9, in <module> from PySide import QtGui File "<frozen importlib._bootstrap>", line 2214, in _find_and_load File "<frozen importlib._bootstrap>", line 2203, in _find_and_load_unlocked File "<frozen importlib._bootstrap>", line 1191, in _load_unlocked File "<frozen importlib._bootstrap>", line 1161, in _load_backward_compatible File "c:\Users\thomas\devel\sf-new\trunk\py2exe-3\testing\py34-32\lib\site-packages\zipextimporter.py", line 86, in load_module return zipimport.zipimporter.load_module(self, fullname) File "c:\Users\thomas\devel\sf-new\trunk\py2exe-3\testing\py34-32\lib\site-packages\PySide\__init__.py", line 41, in <module> _setupQtDirectories() File "c:\Users\thomas\devel\sf-new\trunk\py2exe-3\testing\py34-32\lib\site-packages\PySide\__init__.py", line 11, in _setupQtDirectories pysideDir = _utils.get_pyside_dir() File "c:\Users\thomas\devel\sf-new\trunk\py2exe-3\testing\py34-32\lib\site-packages\PySide\_utils.py", line 97, in get_pyside_dir return _get_win32_case_sensitive_name(os.path.abspath(os.path.dirname(QtCore.__file__))) File "c:\Users\thomas\devel\sf-new\trunk\py2exe-3\testing\py34-32\lib\site-packages\PySide\_utils.py", line 88, in _get_win32_case_sensitive_name path = _get_win32_long_name(_get_win32_short_name(s)) File "c:\Users\thomas\devel\sf-new\trunk\py2exe-3\testing\py34-32\lib\site-packages\PySide\_utils.py", line 63, in _get_win32_short_name raise WinError() FileNotFoundError: [WinError 3] Das System kann den angegebenen Pfad nicht finden. So, the exe still does not work but we see the problem: the call to _utils.get_pyside_dir() in PySide\__init__.py fails. The reason is that in PySide tries to determine the real filename of the QtCore.pyd file; but this fails. So, the problem seems to be in the PySide code; it does not work when PySide is loaded from a zipfile. I wonder if the code in PySide/__init__.py: _setupQtDirectories() is really needed; for my tests the simple exe works ok when I comment out this function. Maybe you can check with the PySide developers? Thomas |