Another issue plotting without X
cultpenguin opened this issue · comments
Thomas Mejer Hansen commented
I want to use the 'Agg' backend to make plots (such that I can create and save figures remotely, without access to an X-server), as I use a remote server to run GeoBiPy.
But, if I do
import matplotlib as mpl
mpl.use('Agg')
import matplotlib.pyplot as plt
from geobipy import LineResults
I get an error impoerting LineResults from geobipy:
(geobipy) tmeha@Arizona:~/$ python pl_results.py
Traceback (most recent call last):
File "pl_results.py", line 15, in <module>
from geobipy import LineResults
File "/mnt/PROGRAMMING/geobipy/geobipy/__init__.py", line 20, in <module>
from .src.base import customPlots
File "/mnt/PROGRAMMING/geobipy/geobipy/src/base/customPlots.py", line 2, in <module>
mpl.use('TkAgg')
File "/home/tmeha/anaconda3/envs/geobipy/lib/python3.7/site-packages/matplotlib/__init__.py", line 1391, in use
switch_backend(name)
File "/home/tmeha/anaconda3/envs/geobipy/lib/python3.7/site-packages/matplotlib/pyplot.py", line 222, in switch_backend
newbackend, required_framework, current_framework))
ImportError: Cannot load backend 'TkAgg' which requires the 'tk' interactive framework, as 'headless' is currently running
A simple trick to allow a user to select the backend is to comment out line 2 in /geobipy/src/base/customPlots.py:
# mpl.use('TkAgg')
- Thomas