public
Created

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.

  • Download Gist
Numpy_Test.py
Python
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
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_()
setup_cx_freeze.py
Python
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
# 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")])

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.