bbfreeze icon indicating copy to clipboard operation
bbfreeze copied to clipboard

bbfreeze not working with new matplotlib

Open georgeBoole opened this issue 12 years ago • 6 comments

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

georgeBoole avatar Sep 11 '13 20:09 georgeBoole

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

schmir avatar Sep 14 '13 19:09 schmir

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.

georgeBoole avatar Sep 16 '13 15:09 georgeBoole

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!

schmir avatar Sep 16 '13 19:09 schmir

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.

rabbah avatar Jan 03 '17 22:01 rabbah

Sorry, but I don't maintain bbfreeze anymore.

schmir avatar Jan 04 '17 22:01 schmir

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

rabbah avatar Jan 05 '17 05:01 rabbah