schmir / bbfreeze

UNMAINTAINED
http://pypi.python.org/pypi/bbfreeze/
92 stars 22 forks source link

bbfreeze not working with new matplotlib #19

Open georgeBoole opened 11 years ago

georgeBoole commented 11 years ago

When trying to use bbfreeze I get the following error:

File "/usr/local/lib/python2.7/dist-packages/bbfreeze-1.1.2-py2.7.egg/bbfreeze/freezer.py", line 590, in call if not self._handleRecipes(): File "/usr/local/lib/python2.7/dist-packages/bbfreeze-1.1.2-py2.7.egg/bbfreeze/freezer.py", line 483, in _handleRecipes if x(self.mf): File "/usr/local/lib/python2.7/dist-packages/bbfreeze-1.1.2-py2.7.egg/bbfreeze/recipes.py", line 236, in recipe_matplotlib mf.import_hook("matplotlib.numerix.random_array", m) File "/usr/local/lib/python2.7/dist-packages/bbfreeze-1.1.2-py2.7.egg/bbfreeze/modulegraph/modulegraph.py", line 257, in import_hook m = self.load_tail(q, tail) File "/usr/local/lib/python2.7/dist-packages/bbfreeze-1.1.2-py2.7.egg/bbfreeze/modulegraph/modulegraph.py", line 341, in load_tail raise ImportError, "No module named " + mname ImportError: No module named matplotlib.numerix

It appears that there changes to matplotlib so that numerix can no longer be referenced in the way it currently is

schmir commented 11 years ago

Which version of matplotlib are you using? Do you like to work on a patch?

georgeBoole commented 11 years ago

matplotlib 1.2.1. I've forked the repo, I can likely work on a fix if you're unable to but any helpful info would be greatly appreciated.

schmir commented 11 years ago

you'll have to patch recipe_matplotlib in bbfreeze/recipes.py

the call to mf.import_hook("matplotlib.numerix.random_array", m) is used to pull in the matplotlib.numerix.random_array module.

it's probably enough to wrap that call in a try...except ImportErrror. If other modules are missing you might want to pull them in with the same method.

Thanks!

rabbah commented 7 years ago

I'm seeing the same with matplotlib==1.5.3 also. Working around this issue (and applying https://github.com/schmir/bbfreeze/pull/33) leads to another:

Traceback (most recent call last):
  File "<string>", line 6, in <module>
  File "__main__.py", line 128, in <module>
  ...
  File "matplotlib/__init__.py", line 1138, in <module>
  File "matplotlib/__init__.py", line 971, in rc_params
  File "matplotlib/__init__.py", line 821, in matplotlib_fname
  File "matplotlib/__init__.py", line 320, in wrapper
  File "matplotlib/__init__.py", line 724, in _get_data_path_cached
  File "matplotlib/__init__.py", line 719, in _get_data_path
RuntimeError: Could not find the matplotlib data files

Bundling the data files helps:

--- a/bbfreeze/recipes.py
+++ b/bbfreeze/recipes.py
@@ -228,13 +228,16 @@ def recipe_matplotlib(mf): 
-    if 0:  # do not copy matplotlibdata. assume matplotlib is installed as egg
+    if True: 

then setting MATPLOTLIBDATA in the environment to a location with the required data file works around this issue.

rm /scratch/dist/matplotlibdata/matplotlibrc
touch /scratch/dist/matplotlibdata/matplotlibrc
MATPLOTLIBDATA=/scratch/dist/matplotlibdata /scratch/dist/frozen

(http://matplotlib.org/users/customizing.html for reference)

caveat: for some reason ldd gets added as a SharedLibrary and must be excluded.

schmir commented 7 years ago

Sorry, but I don't maintain bbfreeze anymore.

rabbah commented 7 years ago

Thanks @schmir - I noticed. I documented the steps for posterity.