Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failed to execute script #2015

Closed
quieromicubita opened this issue May 30, 2016 · 10 comments
Closed

Failed to execute script #2015

quieromicubita opened this issue May 30, 2016 · 10 comments
Assignees

Comments

@quieromicubita
Copy link

quieromicubita commented May 30, 2016

After I get the .exe with Pyinstaller I try to run the application and it pops this message 'Failed to execute script'.

The application runs 'correctly' if I comment the following line of code:

# i_path = ipath[count]

The line above is within a for loop to store paths for 10 images which are button icons added dynamically:

for i in range(len(pos)):
            if i == 0:
                grid.addWidget(self.edit, 0, 3)
            elif i >= 4 and i <= 15:
                count = i-4
                button = QtGui.QPushButton()
                button.setObjectName(self.key_names[count])
                # i_path = ipath[count]
                # icon = QtGui.QIcon(i_path)
                # icon.setThemeName(i_path)
                # button.setIcon(icon)
                # button.setIconSize(QtCore.QSize(70,70))
                grid.addWidget(button, pos[i][0], pos[i][1])
                button.clicked.connect(self.buttonClick)
            (code continues with other elif)

The error occurs when running the application. There isn´t any error message when running Pyinstaller.

The application runs correctly without building the exe, by just running the .py file it shows the app exactly as desired.

Pyinstaller: 3.3.dev0+8756735
Python 2.7.10
Platform: Windows -7-6.1.7601-SP1

Building with the following commands: --onefile --noupx --windowed --icon=entercodescreen.ico entercodescreen.py

The warning file in the 'build' directory has a long list of missing modules but I don´t know how to interpret warnings yet.

@codewarrior0
Copy link
Contributor

Build the app without --windowed and run it from a command prompt to get the full error output.

@quieromicubita
Copy link
Author

Thanks for a quick answer. I got this message:

C:\Python27\My Projects\Pos\dist>entercodescreen.exe
Traceback (most recent call last):
File "entercodescreen.py", line 115, in
File "entercodescreen.py", line 109, in main
File "entercodescreen.py", line 14, in init
File "entercodescreen.py", line 56, in initUI
IndexError: list index out of range
Failed to execute script entercodescreen

Now, why does the .py file run correctly then?

@codewarrior0
Copy link
Contributor

I don't know. You'll have to do some debugging on your own and find out why ipath isn't getting set correctly when frozen. Maybe it's being set using a list of data files that are in your source folder but aren't in the frozen app.

To add data files to the frozen app, see http://pyinstaller.readthedocs.io/en/latest/spec-files.html#adding-files-to-the-bundle

@quieromicubita
Copy link
Author

You're right. I built without --onefile and I can´t see the dir where I have the images. I´ll check the link you suggested to see how to include the images directory.

Thanks.

@htgoebel
Copy link
Member

I take this as "solved".

@quieromicubita
Copy link
Author

Solved indeed. Thanks a lot. I looked at the link you suggested and ended up learning about how to change the .spec script and how to add files and directories. Now the bundled app runs 100% !! In fact, I´ll call my 'own' .spec scripts from now on.

@ebadali
Copy link

ebadali commented Oct 25, 2016

@quieromicubita can you share your .spec file ?

@ghost
Copy link

ghost commented Dec 21, 2016

+1 share

@Sashkiv
Copy link

Sashkiv commented Jan 17, 2017

@LipillaiDave @ebadali Problem solved with run .spec script (pyinstaller main.spec)
My spec script is:

# -*- mode: python -*-

block_cipher = None


a = Analysis(['main.py'],
             pathex=['e:\\myapp'],
             binaries=[],
             datas=[('e:\\myapp\\templates\\main.glade', 'templates')],
             hiddenimports=[],
             hookspath=[],
             runtime_hooks=[],
             excludes=[],
             win_no_prefer_redirects=False,
             win_private_assemblies=False,
             cipher=block_cipher)

pyz = PYZ(a.pure, a.zipped_data,
             cipher=block_cipher)

exe = EXE(pyz, a.scripts, exclude_binaries=True,
          name='Title of app', debug=False, strip=False,
          upx=True, console=False)

coll = COLLECT(exe, a.binaries, a.zipfiles, a.datas,
               strip=False, upx=True, name='myapp')

@itsalfredakku
Copy link

get all libraries used in the script from Lib\site-packages to your application directory
will work

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 17, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

6 participants