Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

System path error with PyQt and Py2exe

My Problem:

I have this problem where if I try to run py2exe on my python file that uses Pyqt/Pyside I get the following error when trying to run the EXE generated in I:\Documents\Python\Buttonio_Testio\dist :

Error recieved when running Package.exe:

I:\Documents\Python\Buttonio_Testio\dist>Package.exe
Traceback (most recent call last):
  File "Package.py", line 1, in <module>
  File "PySide\__init__.pyc", line 55, in <module>
  File "PySide\__init__.pyc", line 11, in _setupQtDirectories
  File "PySide\_utils.pyc", line 87, in get_pyside_dir
  File "PySide\_utils.pyc", line 83, in _get_win32_case_sensitive_name
  File "PySide\_utils.pyc", line 58, in _get_win32_short_name
WindowsError: [Error 3] The system cannot find the path specified.

My setup.py looks like this:

    from distutils.core import setup
    import py2exe

    setup(console=['Package.py'])

My program, in Package.py looks like this:

from PySide.QtCore import *
from PySide.QtGui import *
import sys

import Gui


class Ui_Dialog(QDialog, Gui.Ui_Dialog):
    #Setupui and function afterwards generated converting XML file made by QT Desiner to python.
    def setupUi(self, Dialog):
        Dialog.setObjectName("Dialog")
        Dialog.resize(279, 295)
        self.textBrowser = QtGui.QTextBrowser(Dialog)
        self.textBrowser.setGeometry(QtCore.QRect(10, 10, 256, 192))
        self.textBrowser.setObjectName("textBrowser")
        self.pushButton = QtGui.QPushButton(Dialog)
        self.pushButton.setGeometry(QtCore.QRect(10, 210, 251, 71))
        self.pushButton.setObjectName("PushButton")

        self.retranslateUi(Dialog)
        QtCore.QObject.connect(self.pushButton, QtCore.SIGNAL("clicked()"), self.textBrowser.clear)
        QtCore.QMetaObject.connectSlotsByName(Dialog)

    def retranslateUi(self, Dialog):
        Dialog.setWindowTitle(QtGui.QApplication.translate("Dialog", "Dialog", None, QtGui.QApplication.UnicodeUTF8))
        self.pushButton.setText(QtGui.QApplication.translate("Dialog", "Clear Spam", None, QtGui.QApplication.UnicodeUTF8))

    def __init__(self, parent=None):
        super(Ui_Dialog, self).__init__(parent)
        self.setupUi(self)
        self.spam()

    def spam(self):
        self.textBrowser.append("SPAM")
        self.textBrowser.append("SPAM")
        self.textBrowser.append("SPAM")
        self.textBrowser.append("LOL")
        self.textBrowser.append("I")
        self.textBrowser.append("AM")
        self.textBrowser.append("SPAMMING")
        self.textBrowser.append("MYSELF")

app = QApplication(sys.argv)
form = Ui_Dialog()
form.show()
app.exec_()

I am running windows 8 with 32bit python and 32bit modules installed. The setup.py file was in the same folder as Package.py when I ran setup.py in Command Prompt. Besides that I don't know what other information may help fix my problem.

That's all, thank you for any answers in advance.

like image 936
user2529777 Avatar asked Jul 07 '13 03:07

user2529777


2 Answers

The problem was that _utils.py used __file__, but __file__ is not available in frozen executables. This has been fixed in PySide 1.2.1 that was released a few days ago (it was fixed by commit 817a5c9bd39d3a22e2a7db9aa497059be57d58d7).

like image 62
Jeroen Dekkers Avatar answered Oct 17 '22 13:10

Jeroen Dekkers


I was desperately looking for a solution to this for the past three hours. I ended up going into the _ _ init_ _.py file in C:\Python27\Lib\site-packages\PySide directory. I changed the last line to the following:

try:
    _setupQtDirectories()
except WindowsError:
    pass

It is ugly I admit. I hope PySide people will fix this soon.

like image 7
foresightyj Avatar answered Oct 17 '22 15:10

foresightyj