# Fig.show() fig.savefig() problem

**URL:** <https://forum.generic-mapping-tools.org/t/fig-show-fig-savefig-problem/2000>\
**Category:** PyGMT Q&A\
**Tags:** gmt\
**Created:** [August 17, 2021, 10:08am UTC](https://forum.generic-mapping-tools.org/t/fig-show-fig-savefig-problem/2000 "2021-08-17T10:08:50Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![JingHuiTong](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/jinghuitong/32/1520_2.png) [@JingHuiTong](https://forum.generic-mapping-tools.org/u/JingHuiTong)\
**Post date:** [August 17, 2021, 10:08am UTC](https://forum.generic-mapping-tools.org/t/fig-show-fig-savefig-problem/2000/1 "2021-08-17T10:08:50Z")

</div>

Hi all,  
When I want to show or savefig the figure, the error( with -V):

> psconvert [DEBUG]: gmt\_check\_executable: Pass to popen: [gs --version 2\> /dev/null]  
> psconvert [DEBUG]: gs --version 2\> /dev/null was successful  
> psconvert [DEBUG]: Ghostscript version: 9.54.0  
> psconvert [DEBUG]: Use PS filename /Users/tong/.gmt/sessions/gmt\_session.53684/gmt\_1.ps-  
> psconvert [DEBUG]: Hidden PS file /Users/tong/.gmt/sessions/gmt\_session.53684/gmt\_1.ps- found  
> psconvert [DEBUG]: Complete partial PS file /Users/tong/.gmt/sessions/gmt\_session.53684/gmt\_1.ps-  
> psconvert [DEBUG]: Size of half-baked PS file = 24216.  
> psconvert [DEBUG]: Fattened up PS file /Users/tong/.gmt/sessions/gmt\_session.53684/gmt\_1.ps-  
> psconvert [INFORMATION]: Processing /Users/tong/.gmt/sessions/gmt\_session.53684/gmt\_1.ps-…  
> psconvert [INFORMATION]: Find HiResBoundingBox …  
> psconvert [DEBUG]: Running: gs -q -dNOSAFER -dNOPAUSE -dBATCH -sDEVICE=bbox -DPSL\_no\_pagefill -dMaxBitmap=2147483647 -dUseFastColor=true ‘/Users/tong/.gmt/sessions/gmt\_session.53684/gmt\_1.ps-’ 2\> ‘/Users/tong/.gmt/sessions/gmt\_session.53684/psconvert\_53684c.bb’  
> gs: Interpreter revision (9540) does not match gs\_init.ps revision (9533).  
> psconvert [ERROR]: System call [gs -q -dNOSAFER -dNOPAUSE -dBATCH -sDEVICE=bbox -DPSL\_no\_pagefill -dMaxBitmap=2147483647 -dUseFastColor=true ‘/Users/tong/.gmt/sessions/gmt\_session.53684/gmt\_1.ps-’ 2\> ‘/Users/tong/.gmt/sessions/gmt\_session.53684/psconvert\_53684c.bb’] returned error 256.  
> psconvert [DEBUG]: Delete /Users/tong/.gmt/sessions/gmt\_session.53684/psconvert\_53684c.bb

I have reconstructed the environment and update gmt to 6.2.0.  
There is pygmt.show\_version() information.  
(I install pygmt in my work environment splitpy\_1 to test it. )

> > > pygmt.show\_versions()  
> > > PyGMT information:  
> > > version: v0.4.1  
> > > System information:  
> > > python: 3.7.10 | packaged by conda-forge | (default, Feb 19 2021, 15:59:12) [Clang 11.0.1]  
> > > executable: /Users/tong/opt/anaconda3/envs/split\_1/bin/python  
> > > machine: Darwin-19.6.0-x86\_64-i386-64bit  
> > > Dependency information:  
> > > numpy: 1.21.2  
> > > pandas: 1.3.2  
> > > xarray: 0.19.0  
> > > netCDF4: 1.5.7  
> > > packaging: 21.0  
> > > ghostscript: 9.54.0  
> > > gmt: 6.2.0  
> > > GMT library information:  
> > > binary dir: /Users/tong/opt/anaconda3/envs/split\_1/bin  
> > > cores: 4  
> > > grid layout: rows  
> > > library path: /Users/tong/opt/anaconda3/envs/split\_1/lib/libgmt.dylib  
> > > padding: 2  
> > > plugin dir: /Users/tong/opt/anaconda3/envs/split\_1/lib/gmt/plugins  
> > > share dir: /Users/tong/opt/anaconda3/envs/split\_1/share/gmt  
> > > version: 6.2.0

Please help me. This is a big problem. Thx !

---

<div class="post-metadata">

**Author:** ![weiji14](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/weiji14/32/33_2.png) [@weiji14](https://forum.generic-mapping-tools.org/u/weiji14)\
**Post date:** [August 17, 2021, 10:27am UTC](https://forum.generic-mapping-tools.org/t/fig-show-fig-savefig-problem/2000/2 "2021-08-17T10:27:14Z")

</div>

Hi @JingHuiTong, thanks for posting a detailed report! Your list of dependencies from `pygmt.show_versions()` seems ok, but I did notice this line in the error log:

```auto
gs: Interpreter revision (9540) does not match gs_init.ps revision (9533).

```

So your installed ghostscript (gs) is 9.54.0, but it seems to be thinking that your postscript (ps) file is built with ghostscript 9.53.3. Did you try re-starting your Python kernel and re-creating the figure from scratch? Something might have went wrong when you upgraded to gmt 6.2.0.

---

<div class="post-metadata">

**Author:** ![JingHuiTong](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/jinghuitong/32/1520_2.png) [@JingHuiTong](https://forum.generic-mapping-tools.org/u/JingHuiTong)\
**Post date:** [August 18, 2021, 1:57am UTC](https://forum.generic-mapping-tools.org/t/fig-show-fig-savefig-problem/2000/3 "2021-08-18T01:57:18Z")

</div>

Hi @weiji14,  
Thanks for your reply!  
In fact, this problem was happened before updating gmt6.2.0.  
Because I encountered this situation, I reinstalled pygmt and update gmt.

Surely, I have tried to re-starting the kernel and re-creating the figure.  
I also tried these steps in jupyter lab and iTerms.  
But the problem still existed.

---

<div class="post-metadata">

**Author:** ![weiji14](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/weiji14/32/33_2.png) [@weiji14](https://forum.generic-mapping-tools.org/u/weiji14)\
**Post date:** [August 19, 2021, 2:14am UTC](https://forum.generic-mapping-tools.org/t/fig-show-fig-savefig-problem/2000/4 "2021-08-19T02:14:30Z")

</div>

Could you try:

1. running `gmt clear all` in the terminal (to clear the session cache), and
2. run `which gs` and show us to output, just need to check that there’s not another ghostscript library somewhere in your $PATH.

---

<div class="post-metadata">

**Author:** ![JingHuiTong](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/jinghuitong/32/1520_2.png) [@JingHuiTong](https://forum.generic-mapping-tools.org/u/JingHuiTong)\
**Post date:** [August 19, 2021, 5:29am UTC](https://forum.generic-mapping-tools.org/t/fig-show-fig-savefig-problem/2000/5 "2021-08-19T05:29:35Z")

</div>

Hi @weiji14,  
I followed your suggestion.  
If I don’t activate the environment, it successfully uses GMT psconvert.  
When I activate the environment, it failed.

Please see the details. Thanks for your patient assistance.

[NO activate environment]  
[Screen Shot 2021-08-19 at 1.27.58 PM|520x129](https://forum.generic-mapping-tools.org/uploads/short-url/sfTUzc1V1HIeLWRn8tefM7b8WCe.png)

[Activate environment]

 ![Screen Shot 2021-08-19 at 1.29.19 PM](https://canada1.discourse-cdn.com/flex047/uploads/gmt/original/2X/6/66c5e6a5c988141518c470de5a39f71c10b7a8b7.png)

---

<div class="post-metadata">

**Author:** ![maxrjones](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/maxrjones/32/2698_2.png) [@maxrjones](https://forum.generic-mapping-tools.org/u/maxrjones)\
**Post date:** [August 19, 2021, 3:27pm UTC](https://forum.generic-mapping-tools.org/t/fig-show-fig-savefig-problem/2000/6 "2021-08-19T15:27:15Z")

</div>

I recommend trying to run your PyGMT code in an environment without the GMT bundle in your path. Did you add the following commands to your .bashrc file in order to use the GMT bundle in terminals not initialized by the app?

```auto
        a) export GMTHOME=/Applications/GMT-6.2.0.app/Contents/Resources
        b) add $GMTHOME/bin to your path
        c) export PROJ_LIB=$GMTHOME/share/proj
        d) export GS_LIB=$GMTHOME/share/ghostscript/9.53.3/Resource/Init
        e) export MAGICK_CONFIGURE_PATH=$GMTHOME/lib/GraphicsMagick/config

```

If so, try commenting them out so that there is no confusion between the conda GMT installation and the bundle installation.

---

<div class="post-metadata">

**Author:** ![JingHuiTong](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/jinghuitong/32/1520_2.png) [@JingHuiTong](https://forum.generic-mapping-tools.org/u/JingHuiTong)\
**Post date:** [August 20, 2021, 1:50am UTC](https://forum.generic-mapping-tools.org/t/fig-show-fig-savefig-problem/2000/7 "2021-08-20T01:50:56Z")

</div>

Dear @maxrjones  
I followed your suggestions, it finally can show the figure !!! 😀  
This solution can temporally solve my problems.  
But I want to solve the root reason for this problem because I will use gmt someday.

---

<div class="post-metadata">

**Author:** ![maxrjones](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/maxrjones/32/2698_2.png) [@maxrjones](https://forum.generic-mapping-tools.org/u/maxrjones)\
**Post date:** [August 20, 2021, 3:14pm UTC](https://forum.generic-mapping-tools.org/t/fig-show-fig-savefig-problem/2000/8 "2021-08-20T15:14:20Z")

</div>

There’s a conflict with the 6.2.0 bundle using a different version of ghostscript than your conda environment that causes problems when both are in your path.

To use GMT, you can either (1) activate the same conda environment that you use for PyGMT (which has GMT installed as a dependency), (2) install a gmt specific conda environment (see below) or (3) temporarily add the bundle to your path and source the associated variables. Options 1 or 2 are the simplest.

Instructions for a gmt specific environment:

```auto
conda create --name gmt --channel conda-forge gmt

```

Then whenever you want to use GMT you can activate the environment:

```auto
conda activate gmt

```
