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

Pyinstaller app doesn't launch, no error (worked previously) #4550

Closed
conlin-matt opened this issue Nov 26, 2019 · 15 comments
Closed

Pyinstaller app doesn't launch, no error (worked previously) #4550

conlin-matt opened this issue Nov 26, 2019 · 15 comments

Comments

@conlin-matt
Copy link

conlin-matt commented Nov 26, 2019

Hello,

Thanks for developing and maintaining such a useful tool. I'm having what seems to be a strange issue and I'm hoping some expert advice could help me solve it. I have a PyQt app, e.g. this:
`

from PyQt5.QtWidgets import *
from PyQt5.QtGui import QFont

class WelcomeWindow(QWidget):

    def __init__(self):
        super().__init__()    
    
        if not QApplication.instance():
            app = QApplication(sys.argv)
        else:
            app = QApplication.instance()    
        
        
        # Left menu box setup #
        bf = QFont()
        bf.setBold(True)
        leftBar1 = QLabel('• Welcome!')
        leftBar1.setFont(bf)
        leftBar2 = QLabel('• Get imagery')
        leftBar3 = QLabel('• Get lidar data')
        leftBar4 = QLabel('• Pick GCPs')
        leftBar5 = QLabel('• Calibrate')
    
        leftGroupBox = QGroupBox('Contents:')
        vBox = QVBoxLayout()
        vBox.addWidget(leftBar1)
        vBox.addWidget(leftBar2)
        vBox.addWidget(leftBar3)
        vBox.addWidget(leftBar4)
        vBox.addWidget(leftBar5)
        vBox.addStretch(1)
        leftGroupBox.setLayout(vBox)
        ########################    
        
        # Right contents box setup #      
        txt = QLabel('Text1')
        txt2 = QLabel('Text2')      
        txt3 = QLabel('Text3')
        contBut = QPushButton('Continue >')
    
        rightGroupBox = QGroupBox()
        hBox1 = QHBoxLayout()
        hBox1.addWidget(txt3)
        hBox1.addWidget(contBut)
        vBox = QVBoxLayout()
        vBox.addWidget(txt)
        vBox.addWidget(txt2)
        vBox.addLayout(hBox1)
        rightGroupBox.setLayout(vBox)
        ############################
    
        # Connect widgets with signals #
        contBut.clicked.connect(self.StartTool)
        ################################
    
        # Full widget layout setup #
        fullLayout = QHBoxLayout()
        fullLayout.addWidget(leftGroupBox)
        fullLayout.addWidget(rightGroupBox)
        self.setLayout(fullLayout)

        self.setWindowTitle('Title')
        self.show()
        ###############################
     
    def StartTool(self):
        self.close()


if __name__ == '__main__':
    import sys
    from PyQt5 import QtWidgets

    if not QtWidgets.QApplication.instance():
        app = QtWidgets.QApplication(sys.argv)
    else:
        app = QtWidgets.QApplication.instance()

    w = WelcomeWindow()
    sys.exit(app.exec_())`

I can successfully freeze this using pyi-makespec --debug all --onefile -n test --icon icon3.ico test.py and pyinstaller test.py. When I launch the program, however, whether it be through the command line or by running the app directly, the app fails to start. I don't get any error messages, the last 4 lines of the output are as follows:

`

# PyQt5.QtWidgets not found in PYZ

[2820] LOADER: Back to parent (RC: -1073741819)

[2820] LOADER: Doing cleanup

[2820] LOADER: Freeing archive status for C:\Users\conli\Documents\SurfRCaT\dist\test.exe`

I'm on a Windows 10 machine, running Python 3.6 with Anaconda (64 bit). I've tried using the most recent development version of PyInstaller. I've tried creating a clean environment. I've tried invoking the app differently. I've tried using --onedir instead. All same result. The strangest part is that this worked just fine before my computer restarted. I'm at quite a loss here as to why the app refuses to launch- any ideas?

@rafael-mq
Copy link

I'm also facing this problem on some Windows 7 and Windows 10 computers.
Python 3.7.4 - 32bits
PyInstaller 4.0 dev
I'm building my program on a single executable.
I tried building it with debug mode on (--debug all) and at some point an error message appears saying it failed to execute script "pyiboot01_bootstrap" just like what was reported at #4213.
I'm reaaly looking forward for an answer on this topic.

@rafael-mq
Copy link

I'm also facing this problem on some Windows 7 and Windows 10 computers.
Python 3.7.4 - 32bits
PyInstaller 4.0 dev
I'm building my program on a single executable.
I tried building it with debug mode on (--debug all) and at some point an error message appears saying it failed to execute script "pyiboot01_bootstrap" just like what was reported at #4213.
I'm reaaly looking forward for an answer on this topic.

I solved the problem in my case downgrading both Python to 3.6.8 and PyInstaller to 3.4.

@JarekParal
Copy link

JarekParal commented Jan 13, 2020

I have the same issue.
When I create an app with pyinstaller (setting onefile, onedir don't matter) and run the app, the app just opens a console window and without any message close the window.
I tested it with Conda 32-bit, Python 3.6.4/3.7.4 and pyinstaller 3.4/3.5/3.6 and everytime a get the same behaviour.

For testing I used just simple script:

# test.py file
if __name__ == '__main__':
    print('__main__ - start')

and call pyinstaller like that: pyinstaller test.py with --onefile or with --onedir flag.

In all of these configurations, the app just opens console windows and close. I also check the output with --debug all, where I got the same output as @conlin-matt:

[28600] LOADER: Running test.py
[28600] LOADER: OK.
[28600] LOADER: Cleaning up Python interpreter.

But when I move the test.py file to subfolder test and call the pyinstaller: pyinstaller test\test.py it suddenly solves this issue and the app start work (show the message __main__ - start in the console window):

[28600] LOADER: Running test.py
__main__ - start
[28600] LOADER: OK.
[28600] LOADER: Cleaning up Python interpreter.

Then this could be a workaround.

For testing purpose, I add my conda env export: environment.txt

@Legorooj
Copy link
Member

@JarekParal try opening a command prompt and running the exe from there - unless you were already doing that? And the subdir thing shouldn't change anything.

@JarekParal
Copy link

@Legorooj I'm not sure if I tried to run the app from command prompt but that isn't a solution for me. I moved the file test.py to a subfolder and it works well for me. But I had to change the import structure.

@Legorooj
Copy link
Member

Hmm. Could you type out a file structure for us (For both the working and not working config)? Eg:

- data-folder
  - data-file.json
  - _another_data.yml
- my_module
  - __init__.py
- main.py

And tell us which pyinstaller command you used?

@JarekParal
Copy link

I tried to create MCVE but I couldn't reproduce this issue on any simple MCVE, which mean that my previous comment about simple test file isn't correct:

# test.py file
if __name__ == '__main__':
    print('__main__ - start')

But I can still reproduce the issue in my code. As it is an internal project, I couldn't share the code base, but I exported at least the build log files.
I tried to build this project first time with file name calmanimo.py and second time with file test.py.
Second build works but the first not.

I found one difference in the xref... files:

  1. https://github.com/JarekParal/pyinstaller-project-structure-issue/blob/build-files/build/calmanimo/xref-calmanimo.html
  2. https://github.com/JarekParal/pyinstaller-project-structure-issue/blob/build-files/build/test/xref-test.html

But I don't understand what is the difference and if that could be an issue.

My project structure is:

- `test.py` or `calmanimo.py
- calmanimo folder
  - __init__.py
  - all other folders with implementation for this app 

The app is base on WxPython and I'm using ctype library for C DLL binding and pythonnet for C# DLL binding + other libraries specify in environment.yml.

@Legorooj
Copy link
Member

Legorooj commented Feb 24, 2020

Wait a sec. You're saying the following folder structure doesn't work:

- calmanimo.py
- calmanimo (dir)
  - __init__.py
  - GUI.py
  - etc

Am I right?

@JarekParal
Copy link

Actually it is more like that:

- calmanimo.py
- calmanimo (dir)
  - __init__.py
  - gui (dir)
    - __init__.py
    - GUI.py
  - etc

But yes, you are right.

@Legorooj
Copy link
Member

Try renaming calmanimo.py to main.py and building. Don't change anything else. @JarekParal

@JarekParal
Copy link

Yes, this seems to fix this issue. Do you know why that happens?

@Legorooj
Copy link
Member

When you import calmanimo, python is trying to import itself, ie calmanimo.py. If you name a python file os.py, and try to import the os module, it'll fail. If you want the python file named that, change the name of the directory to something like _calmanimo

@Legorooj
Copy link
Member

@conlin-matt have you tried with the latest version of PyInstaller?

@conlin-matt
Copy link
Author

I haven't tried since November. I ended up having so many issues with this that I switched gears to fbs, a great package that puts a nice wrapper on Pyinstaller. That being aid, I've had success building some (simpler) apps with Pyinstaller since then, so I don't think whatever was going on here serves as an Issue for Pyinstaller anymore. As far as I'm concerned this issue seems resolved.

@Legorooj
Copy link
Member

@conlin-matt I'll close then. In case you're interested, I've got a PyInstaller GUI I'm in late development stages with. It'll be released soon.

@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.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants