Skip to content

Instantly share code, notes, and snippets.

@fzumstein
Created February 21, 2013 19:26
Show Gist options
  • Save fzumstein/5007372 to your computer and use it in GitHub Desktop.
Save fzumstein/5007372 to your computer and use it in GitHub Desktop.
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\__init__.py", 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()
layout.addWidget(self.label)
self.setLayout(layout)
# Test NumPy call
a = numpy.eye(5)
self.label.setText(str(a[0,0]))
# Run App
app = QApplication(sys.argv)
form = Form()
form.show()
app.exec_()
# Run from the command prompt like this: python setup_cx_freeze.py 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('Numpy_Test.py', base=base, targetName="NumpyTest.exe")])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment