DOI-USGS / geobipy

Geophysical Bayesian Inference in Python. Docs:

Home Page:https://usgs.github.io/geobipy/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Another issue plotting without X

cultpenguin opened this issue · comments

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

Hey Thomas,

I did not originally intend for that line in customPlots to be pushed to the repo and it looks like I accidentally added it..... thanks for pointing it out, I will remove it. Does this fix #15 ?