Create a gist now

Instantly share code, notes, and snippets.

Minimalistic PyQt/NumPy sample with cx_Freeze setup file to show that the frozen app doesn't work with NumPy 1.7.0 under Python 2.7.3: It gives the following error: ...numpy\", line 147, in <module> from core import * AttributeError: 'module' object has no atttribute 'sys' ----With NumPy 1.6.2 it works fine though.
from PyQt4.QtGui import QDialog, QLabel, QVBoxLayout, QApplication
import sys
import numpy
class Form(QDialog):
def __init__(self, parent=None):
super(Form, self).__init__(parent)
# PyQt4 Layout
self.label = QLabel('')
layout = QVBoxLayout()
# Test NumPy call
a = numpy.eye(5)
# Run App
app = QApplication(sys.argv)
form = Form()
# Run from the command prompt like this: python build
import sys
from cx_Freeze import setup, Executable
includefiles = []
includes = ['PyQt4.QtCore']
build_exe_options = {'packages': [],
'excludes': ['tkinter'],
'includes': includes,
'include_files': includefiles}
base = None
if sys.platform == 'win32':
base = 'Win32GUI'
setup( name = 'NumpyTest',
version = '1.0',
description = 'Test',
options = {'build_exe': build_exe_options},
executables = [Executable('', base=base, targetName="NumpyTest.exe")])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment