Skip to content
New issue

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

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

Already on GitHub? # to your account

IOError: Could not find english language file after converting script to exe using py2exe #19

Closed
mistrics opened this issue Aug 26, 2014 · 8 comments

Comments

@mistrics
Copy link

Hi,

I have made a small script that is using Gooey and when I converted it to a exe using py2exe or pythonInstaller I am getting following problem.

Traceback (most recent call last):
File "command_ui.py", line 1, in
File "gooey__init__.pyc", line 1, in
File "gooey\gooey_decorator.pyc", line 16, in
File "gooey\gui\base_window.pyc", line 16, in
File "gooey\gui\header.pyc", line 10, in
File "gooey\i18n.pyc", line 37, in
File "gooey\i18n.pyc", line 24, in get_path
IOError: Could not find english language file

@mistrics
Copy link
Author

It is working fine when executed using .py

@mistrics
Copy link
Author

With latest code I inserted a print statement and got following.

File is already present at location mentioned.
Can .zip location be a problem?

C:\GooeyTest\dist\library.zip\gooey\languages/english.json
Traceback (most recent call last):
File "command_ui.py", line 28, in
File "gooey\gooey_decorator.pyc", line 37, in inner
File "gooey\i18n.pyc", line 40, in load
IOError: [Errno Language file not found. Make sure that your ] translation file is in the languages directory,

@chriskiehl
Copy link
Owner

Hey Devendra,

(I'm responding to your email here as well so everything is tidy and in the same spot for easy reference :)

I've never used py2exe before -- I've always used PyInstaller for creating executables, so I'm not immediately sure what the root of the issue is. I won't be able to dig into this issue till the weekend, but my first guess (assuming py2exe and PyInstaller work kind of the same) is that you'll need to have a separate resources folder with stuff like languages and graphics if you want to have it run as a stand alone executable.

To test this, I'd suggest patching the i18n module in Gooey to look for the language file in the current working dir. That way you could test if it is indeed a simple resource path problem by placing the language json file in the same directory as the one your executable is in.

For example, line 17 in i18n could be changed to:

_DEFAULT_DIR = os.getcwd()  

This would make Gooey look in the same directory in which is is executing.

If that does work, then the next error you'll get will be one for missing images. For which you would need to repeat the same process.

Like I said, just a first guess. I'll look into it more this weekend.

@mistrics
Copy link
Author

It worked well with the above fix.

BUT Now I am getting some other issue.

Traceback (most recent call last):
File "", line 26, in
File "C:\Anant-WS\build\command_ui\out00-PYZ.pyz\gooey.gooey_decorator", line 47, in inner
File "C:\Anant-WS\build\command_ui\out00-PYZ.pyz\gooey.gooey_decorator", line 76, in get_parser
File "C:\Anant-WS\build\command_ui\out00-PYZ.pyz\gooey.source_parser", line 155, in extract_parser
File "C:\Anant-WS\build\command_ui\out00-PYZ.pyz\gooey.source_parser", line 46, in parse_source_file
File "C:\Anant-WS\build\command_ui\out00-PYZ.pyz\ast", line 37, in parse
TypeError: compile() expected string without null bytes

This happens for both py2exe and pythonInstaller

@xaroth8088
Copy link

For future reference, I was able to get to the same point as @devendramistri above without modifying Gooey, just by telling the PyInstaller-generated spec file where to find the language and image files for inclusion in the distribution output:

...rest of spec file above...

# Include Gooey's dependencies
gooey_languages = Tree('C:/Python27/Lib/site-packages/gooey/languages', prefix = 'gooey/languages')
gooey_images = Tree('C:/Python27/Lib/site-packages/gooey/images', prefix = 'gooey/images')

coll = COLLECT(exe,
               a.binaries,
               a.zipfiles,
               a.datas,
               gooey_languages,
               gooey_images,
               strip=None,
               upx=True,
               name='main')

...rest of spec file below...

@xaroth8088
Copy link

Not that I'm sure what the right answer is, but it appears the root cause is that the filename that gets passed into gooey.source_parser::parse_source_file() is the windows .exe that was generated by py2exe or PyInstaller.

@xaroth8088
Copy link

A small side note: now that #43 and #42 are fixed, if you have a program that doesn't require argparse it can successfully be packaged and run (since gooey.source_parser::parse_source_file() never needs to be called in that case).

@chriskiehl
Copy link
Owner

Closing this. Super old and no longer sure if even relevant. Plus, PyInstaller and cxFreeze have since emerged as the preferred ways of packaging Gooey.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants