Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8089241
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T19:20:33+00:00 2026-06-05T19:20:33+00:00

I have a problem trying to turn my python code into an executable using

  • 0

I have a problem trying to turn my python code into an executable using pyinstaller. I’m using PyQT 4.9.1 and Python 2.7.

I am getting the error when I try and build it (Build.py):

Traceback (most recent call last):
  File "Build.py", line 1494, in <module>
    main(args[0], configfilename=opts.configfile)
  File "Build.py", line 1472, in main
    build(specfile)
  File "Build.py", line 1429, in build
    execfile(spec)
  File "c:\projects\vibot\vibotUI_07.py", line 270, in <module>
    window = viUI()
  File "c:\projects\vibot\vibotUI_07.py", line 9, in __init__
    QtGui.QMainWindow.__init__(self)
NameError: global name 'QtGui' is not defined

I have searched google and all the solutions are based on correcting improper importing of modules, but I already did it properly to begin with.

Here is a cropped version of my code:

#!/usr/bin/env python

import sys
import os
from PyQt4 import QtCore, QtGui

class viUI(QtGui.QMainWindow):
    def __init__(self):
        QtGui.QMainWindow.__init__(self)
        self.setWindowTitle('test')
        self.setObjectName('viMainWindow')
        self.resize(400, 600)

        self.show()

app = QtGui.QApplication(sys.argv)
window = viUI()
sys.exit(app.exec_())

This is the Makespec.py file:

# -*- mode: python -*-
a = Analysis([os.path.join(HOMEPATH,'support\\_mountzlib.py'), os.path.join(HOMEPATH,'support\\useUnicode.py'), 'c:\\projects\\vibot\\vibotUI_07.py'],
             pathex=['c:\\Python\\pyinstaller-1.5.1\\pyinstaller-1.5.1'])
pyz = PYZ(a.pure)
exe = EXE( pyz,
          a.scripts,
          a.binaries,
          a.zipfiles,
          a.datas,
          name=os.path.join('dist', 'vibotUI_07.exe'),
          debug=False,
          strip=False,
          upx=True,
          console=True )
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T19:20:34+00:00Added an answer on June 5, 2026 at 7:20 pm

    It looks to me like you’re calling Build.py and passing your script as a paramter. I just tested this to see what would happen and got the same output that you posted.

    With the current stable PyInstaller (1.5.1) you need to create a spec file first. Instead of Build.py run MakeSpec.py with your script as an argument. This will create a .spec file that you then send to Build.py.

    The documentation shows options you can pass to MakeSpec for things like setting an icon under Windows and setting deployment options. These options all go into the spec file so that you just need to call Build.py again when you need to rebuild your application.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a problem when trying to execute this update statement (below) using C#
I have this problem when trying to run hello world program using android SDK.
I have run into a problem trying to modify a form I myself have
im currently learning jQuery and have ran into a problem. I am trying to
I have a problem with a small app I'm trying to build. When I
I have some json coming like the below, which i'm trying to turn into
I have a problem trying to design some generic storage.. Basically I have the
I have a problem trying to edit. I work with Areas for better management
I have a problem trying to hide .php extension from the url I have
I implemented the table sorter yesterday and i have a problem trying to change

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.