0

I got the following error after installing Modin with dask on my Mac and trying to parallelise some pandas code:

RuntimeError: Python is not installed as a framework. The Mac OS X backend will not be able to function correctly if Python is not installed as a framework. 

Here's a part of the stack trace:

  File "/Users/x/miniconda3/lib/python3.6/runpy.py", line 96, in _run_module_code
  mod_name, mod_spec, pkg_name, script_name)
  File "/Users/borismetodiev/miniconda3/lib/python3.6/runpy.py", line 85, in _run_code
  exec(code, run_globals)
  File "/Users/x/src/test-data-generator/data-generator/x/scripts/train_model.py", line 36, in <module>
  from x import app
  File "/Users/x/src/data-generator/test-data-generator/x/x/app.py", line 15, in <module>
  import matplotlib.pyplot as plt
  File "/Users/x/miniconda3/lib/python3.6/site-packages/matplotlib/pyplot.py", line 115, in <module>
  _backend_mod, new_figure_manager, draw_if_interactive, _show = pylab_setup()
  File "/Users/x/miniconda3/lib/python3.6/site-packages/matplotlib/backends/__init__.py",      line 32, in pylab_setup
  globals(),locals(),[backend_name],0)
  File "/Users/borismetodiev/miniconda3/lib/python3.6/site- packages/matplotlib/backends/backend_macosx.py", line 19, in <module>
 from matplotlib.backends import _macosx

I had come across this error before and was able to solve the problem by installing py and running scripts with python instead of python, so why does matplotlib suddenly think that I don't have python installed as a framework?

I ran pip install "modin[dask]", then pip install "dask[dataframe]", and then imported modin.pandas. Any help would be much appreciated.

Boris
  • 716
  • 1
  • 4
  • 25
  • Duplciate of [python matplotlib framework under macosx?](https://stackoverflow.com/questions/4130355/python-matplotlib-framework-under-macosx) – Yohann L. Nov 18 '19 at 10:54
  • One of the easier solution is just to put `import matplotlib` and then `matplotlib.use('TkAgg')` before importing pyplot – Yohann L. Nov 18 '19 at 10:55
  • @Yohann L. it's not a duplicate because I already have python installed as a framework, which is a solution to the problem in the question you linked. pyplot is being imported by matplotlib, are you suggesting changing the source code in matplotlib/backends/backend_macosx.py? – Boris Nov 18 '19 at 10:58
  • 1
    You can juste put it this two lines before `import matplotlib.pyplot as plt` in `../x/app.py`. This is one of your code app.py ? – Yohann L. Nov 18 '19 at 11:01
  • @Yohann L. you're right, sorry I hadn't seen that before. Could you elaborate on what the TkAgg backend is and why it's appropriate in this case? – Boris Nov 18 '19 at 11:11
  • I couldn't really help you, I'm not an expert. I've just deal with the same problem on my mac. There is some explanation on TkAgg backed on the question I linked and on matplotlib documentation https://matplotlib.org/faq/usage_faq.html#what-is-a-backend – Yohann L. Nov 18 '19 at 12:20

0 Answers0