简体   繁体   中英

Opening PyGTK Python Module Error in py2exe

I have a project written in Python 2.7 and PyGTK, with py2exe for compiling. I have two modules, "Launchpad.py" and "RegistrationScreen.py". I need to open RegistrationScreen.py from Launchpad.py.

I am using the following code currently:

def open_registration(event, data=None):
    subprocess.Popen(["python", "RegistrationScreen.py"])

This works fine when I test - the window is opened without the shell window opening.

However, when I compile using py2exe, I get the following log error on executing the created application.

Traceback (most recent call last): File "Launchpad.py", line 26, in open_registration File "subprocess.pyc", line 672, in init
File "subprocess.pyc", line 882, in _execute_child WindowsError: [Error 2] The system cannot find the file specified

How do I fix my code so py2exe will compile it correctly? Is there another way I can open the RegistrationScreen.py module's window from Launchpad.py, that won't throw errors in the final.exe file?

The problem is the path. RegistrationScreen.py is (probably) compressed inside dist/library.zip, but your code that calls it is looking for it in dist/RegestrationScreen.py.

I don't know what the best solution to this is... py2exe is kind of a pain for accessing files.

Also, you probably don't want to be doing subprocess.Popen(["python", "RegistrationScreen.py"]) because you can't guarantee your users will have python installed and accessible systemwide. If you really need a separate process, then maybe you should run py2exe on RegistrationScreen.py individually to create a separate.exe, and then include that in the dist folder of your main.exe?

I know that's somewhat convoluted, but it would probably work. And as I said, there might be a better way.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM