Problem compiling python in pyqt libraries, with py2exe

Asked

Viewed 420 times

1

I’m trying to compile with py2exe, but when I compile from error.

Let me give you an example of this error, with Python 2.7 64-bit programs, pyqt4 for Python 2.7, and py2exe for Python 2.7.

Follow the example:

Create a file teste.py bodily:

import sys  
from PyQt4 import QtGui, uic

Create a file setup.py with the body:

from distutils.core import setup  
import py2exe
setup(console=['teste.py'])

Afterwards Compile:

python setup.py py2exe

And the error occurs:

error: compiling
'C:\Python27\lib\site-packages\PyQt4\uic\port_v3\proxy_base.py' failed
SyntaxError: invalid syntax <proxy_base.py, line 26>

1 answer

1

According to the information on this site:
Pyqt 4.7 and py2exe error

There is a recommendation to remove (or temporarily move to some other location), the directory port_v3, that in your question is on the way:

C:\Python27\lib\site-packages\PyQt4\uic\port_v3

On this other site:
Pyqt4 compiling issues

There is a recommendation for in addition to removing the folder port_v3, use the following command to generate the executable:

python "setup.py py2exe --includes sip"

A hint: before you remove the folder, you can try the above command to generate the executable and, if it doesn’t work, try removing the folder and generating again (with the full command including the sip).

  • It now gave the following error: error: [Errno 2] No such file or directory: 'MSVCP90.dll'

  • You have the Microsoft Visual C++ Compiler for Python 2.7 installed? If not, you need to install and put the directory bin VC on your PATH (the path it installs is something like: C:\Users\seu_usuario\AppData\Local\Programs\Common\Microsoft\Visual C++ for Python\9.0\VC\bin or, run at the prompt, the command C:\Users\seu_usuario\AppData\Local\Programs\Common\Microsoft\Visual C++ for Python\9.0\vcvarsall.bat (best solution) before generating the exe. If it works, let me know to update the answer

  • I installed the program that you suggested, I added it in the path, ran the script, and still keep complaining about MSVCP90.dll

  • I figured out how to solve the problem, so remove the dll when compiling like this: setup(options = {"py2exe": { "dll_excludes": ["MSVCP90.dll"]}}, console=['test.py.'])

  • Now I tried to compile the complete code, the complete compilation, but at the time of opening the program the following error: Import Error: No module named Qtnetwork

  • I’ve been doing some research and discovered more options, now I’m improving the compiler code: setup(options = {"py2exe": { "dll_excludes": ["MSVCP90.dll"], "includes":["Sip", "Pyqt4", "Pyqt4.Qtnetwork", "Pyqt4.Qtwebkit"]}}, console=['program.py']) However it is still complaining No module named Qtwebkit.Qwebview

  • Has an answer here in the OS (in English) talking about this error. And another here saying to confirm that Qt is installed with Webkit and that there is a Qt library in the path C:\python2.7\site-packages\PyQt4. Maybe it’ll help!

  • Inside the folder C: Python27 Lib site-Packages Pyqt4 Sip Pyqt4 Qtwebkit there is a file called qwebview.Sip, but I don’t know how it helps to know this

  • @Megaanim in the post, the author refers to the Linux system library, with extension so. In Windows, it probably should be a file dll.

  • but Voce saw what I said? With normal python works the component.. When I do & #Xa;python program.py the program works, the qwebview component opens normal. The error only gives when compiling the program with py2exe

  • In linux there is something like py2exe, this is only for windows, so I don’t see what would help something that has to do with linux, in a compiler that has only for windows

  • @Megaanim Really, the py2exe is unique to the Windows platform. However, to generate a portable exe, the py2exe need to put all program dependencies (dlls, modules, etc.) inside the exe file. What is probably happening is that the executable is not finding any library (or module) needed for the execution.

  • This I had already understood, as you can see my comments above I include, Sip, Pyqt4, and Pyqt4.Qtnetwork, and Pyqt4.QtWebKit.. What else I have to include, that’s my doubt

  • @Megaanim The problem you presented in question Original was solved, right? Please, if you have any questions, ask a new question about the problem that appeared later, with details and everything you tried

  • And then you got it? I’m reading the comments and the subject died...

Show 10 more comments

Browser other questions tagged

You are not signed in. Login or sign up in order to post.