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

matplotlib and wx #169

Closed
infinity77 opened this issue Dec 19, 2022 · 5 comments
Closed

matplotlib and wx #169

infinity77 opened this issue Dec 19, 2022 · 5 comments
Labels
bug Something isn't working

Comments

@infinity77
Copy link

This is somehow related to #71 .

The hook for matplotlib looks like this:

image

How about I am using wxPython for my interface?

This ends up putting "wx" in the list of excluded packages, and of course py2exe bombs out like this:

Traceback (most recent call last):
File "C:\Users\Whatever\MyProject\setup.py", line 1404, in
BuildPy2Exe(architecture)
File "C:\Users\Whatever\MyProject\setup.py", line 739, in BuildPy2Exe
setup(
File "C:\Users\Whatever\python-3.9.10.amd64\lib\site-packages\setuptools_distutils\core.py", line 148, in setup
return run_commands(dist)
File "C:\Users\Whatever\python-3.9.10.amd64\lib\site-packages\setuptools_distutils\core.py", line 163, in run_commands
dist.run_commands()
File "C:\Users\Whatever\python-3.9.10.amd64\lib\site-packages\setuptools_distutils\dist.py", line 967, in run_commands
self.run_command(cmd)
File "C:\Users\Whatever\python-3.9.10.amd64\lib\site-packages\setuptools_distutils\dist.py", line 986, in run_command
cmd_obj.run()
File "C:\Users\Whatever\python-3.9.10.amd64\lib\site-packages\py2exe\distutils_buildexe.py", line 204, in run
self._run()
File "C:\Users\Whatever\python-3.9.10.amd64\lib\site-packages\py2exe\distutils_buildexe.py", line 284, in _run
builder.analyze()
File "C:\Users\Whatever\python-3.9.10.amd64\lib\site-packages\py2exe\runtime.py", line 176, in analyze
mf.import_hook(modname)
File "C:\Users\Whatever\python-3.9.10.amd64\lib\site-packages\py2exe\vendor\modulefinder.py", line 215, in import_hook
q, tail = self.find_head_package(parent, name)
File "C:\Users\Whatever\python-3.9.10.amd64\lib\site-packages\py2exe\vendor\modulefinder.py", line 284, in find_head_package
raise ImportError(f'Module {name} is in the "excludes" list')
ImportError: Module wx is in the "excludes" list

@albertosottile
Copy link
Member

Hi, thanks for reporting this. If you look at blame in that area, you will see that call to excludes was added 8 years ago, way before I started using py2exe. I have no idea if that exclusion is still needed nowadays. My question for you would be: can you try to comment that line and freeze your code? Does it work after?

@albertosottile albertosottile added bug Something isn't working requires user input labels Dec 20, 2022
@infinity77
Copy link
Author

Hi, not looking to blame anyone, this is open source after all. It just seemed weird to preemptively exclude wx as it is one of the main backends of matplotlib.

it works if I comment out that line.

@albertosottile
Copy link
Member

Sorry, with blame I meant git blame -> https://github.com/py2exe/py2exe/blame/master/py2exe/hooks.py#L379

Perhaps the name of this feature is too harsh... anyway, I did not feel any actual blame from your side, no worries.

Thanks for confirming that matplotlib works also with wx. I will give a look about patching this, but I am away from home for the holidays so this might take a while.

@zobac
Copy link

zobac commented Apr 14, 2023

I've found that if I put wx first in the includes list (before matplotlib) it will be ignored in the excludes list when added by matplotlib. This results in wx ending up in the .zip file.

@albertosottile
Copy link
Member

Fixed in 0.13.0.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants