Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

psconvert [ERROR]: Cannot execute Ghostscript (gs). #393

Closed
tjcrone opened this issue Feb 4, 2020 · 11 comments
Closed

psconvert [ERROR]: Cannot execute Ghostscript (gs). #393

tjcrone opened this issue Feb 4, 2020 · 11 comments

Comments

@tjcrone
Copy link

tjcrone commented Feb 4, 2020

After a fresh install in a conda environment as per the installation instructions, I get the following error when trying to make my first figure:

psconvert [ERROR]: Cannot execute Ghostscript (gs).
---------------------------------------------------------------------------
GMTCLibError                              Traceback (most recent call last)
<ipython-input-5-6ebedab27258> in <module>
----> 1 fig.show()

~/.conda/envs/axial/lib/python3.8/site-packages/pygmt/figure.py in show(self, dpi, width, method)
    269             img = None
    270         elif method == "static":
--> 271             png = self._preview(
    272                 fmt="png", dpi=dpi, anti_alias=True, as_bytes=True, transparent=True
    273             )

~/.conda/envs/axial/lib/python3.8/site-packages/pygmt/figure.py in _preview(self, fmt, dpi, as_bytes, **kwargs)
    342         """
    343         fname = os.path.join(self._preview_dir.name, "{}.{}".format(self._name, fmt))
--> 344         self.savefig(fname, dpi=dpi, **kwargs)
    345         if as_bytes:
    346             with open(fname, "rb") as image:

~/.conda/envs/axial/lib/python3.8/site-packages/pygmt/figure.py in savefig(self, fname, transparent, crop, anti_alias, show, **kwargs)
    223             kwargs["W"] = "+k"
    224 
--> 225         self.psconvert(prefix=prefix, fmt=fmt, crop=crop, **kwargs)
    226         if show:
    227             launch_external_viewer(fname)

~/.conda/envs/axial/lib/python3.8/site-packages/pygmt/helpers/decorators.py in new_module(*args, **kwargs)
    181                 if alias in kwargs:
    182                     kwargs[arg] = kwargs.pop(alias)
--> 183             return module_func(*args, **kwargs)
    184 
    185         new_module.aliases = aliases

~/.conda/envs/axial/lib/python3.8/site-packages/pygmt/helpers/decorators.py in new_module(*args, **kwargs)
    291                         )
    292             # Execute the original function and return its output
--> 293             return module_func(*args, **kwargs)
    294 
    295         return new_module

~/.conda/envs/axial/lib/python3.8/site-packages/pygmt/figure.py in psconvert(self, **kwargs)
    163             kwargs["A"] = ""
    164         with Session() as lib:
--> 165             lib.call_module("psconvert", build_arg_string(kwargs))
    166 
    167     def savefig(

~/.conda/envs/axial/lib/python3.8/site-packages/pygmt/clib/session.py in call_module(self, module, args)
    496         )
    497         if status != 0:
--> 498             raise GMTCLibError(
    499                 "Module '{}' failed with status code {}:\n{}".format(
    500                     module, status, self._error_message

GMTCLibError: Module 'psconvert' failed with status code 78:
psconvert [ERROR]: Cannot execute Ghostscript (gs).

Here is the output from conda list:

(axial) jovyan@jupyter-tjcrone:~$ conda list
# packages in environment at /home/jovyan/.conda/envs/axial:
#
# Name                    Version                   Build  Channel
_libgcc_mutex             0.1                 conda_forge    conda-forge
_openmp_mutex             4.5                       0_gnu    conda-forge
atk                       2.32.0               haf93ef1_0    conda-forge
backcall                  0.1.0                      py_0    conda-forge
boost-cpp                 1.70.0               h8e57a91_2    conda-forge
bzip2                     1.0.8                h516909a_2    conda-forge
ca-certificates           2019.11.28           hecc5488_0    conda-forge
cairo                     1.16.0            hfb77d84_1002    conda-forge
certifi                   2019.11.28               py38_0    conda-forge
cfitsio                   3.470                hb60a0a2_2    conda-forge
cftime                    1.0.4.2                  pypi_0    pypi
chrpath                   0.16              h14c3975_1001    conda-forge
curl                      7.65.3               hf8cf82a_0    conda-forge
dbus                      1.13.6               he372182_0    conda-forge
dcw-gmt                   1.1.4                      1001    conda-forge
decorator                 4.4.1                      py_0    conda-forge
entrypoints               0.3                   py38_1000    conda-forge
expat                     2.2.9                he1b5a44_2    conda-forge
ffmpeg                    4.2                  h167e202_0    conda-forge
fftw                      3.3.8           nompi_h7f3a6c3_1110    conda-forge
fontconfig                2.13.1            h86ecdb6_1001    conda-forge
freetype                  2.10.0               he983fc9_1    conda-forge
freexl                    1.0.5             h14c3975_1002    conda-forge
fribidi                   1.0.5             h516909a_1002    conda-forge
gdal                      3.0.4            py38hbb6b9fb_0    conda-forge
gdk-pixbuf                2.38.2               h3f25603_0    conda-forge
geos                      3.8.0                he1b5a44_0    conda-forge
geotiff                   1.5.1                h38872f0_8    conda-forge
gettext                   0.19.8.1          hc5be6a0_1002    conda-forge
ghostscript               9.22              hf484d3e_1001    conda-forge
giflib                    5.2.1                h516909a_1    conda-forge
glib                      2.58.3          py38h6f030ca_1002    conda-forge
gmp                       6.2.0                he1b5a44_1    conda-forge
gmt                       6.0.0                hed9e446_1    conda-forge
gnuplot                   5.2.7                h0fb2448_3    conda-forge
gnutls                    3.6.5             hd3a4fd2_1002    conda-forge
gobject-introspection     1.58.2          py38h5503ade_1002    conda-forge
graphicsmagick            1.3.33               h40aeb3c_0    conda-forge
graphite2                 1.3.13            hf484d3e_1000    conda-forge
gshhg-gmt                 2.3.7                      1002    conda-forge
gst-plugins-base          1.14.5               h0935bb2_1    conda-forge
gstreamer                 1.14.5               h36ae1b5_1    conda-forge
gtk2                      2.24.32              h586f36d_1    conda-forge
harfbuzz                  2.4.0                h9f30f68_3    conda-forge
hdf4                      4.2.13            hf30be14_1003    conda-forge
hdf5                      1.10.5          nompi_h3c11f04_1104    conda-forge
icu                       64.2                 he1b5a44_1    conda-forge
ipykernel                 5.1.4            py38h5ca1d4c_0    conda-forge
ipython                   7.12.0           py38h5ca1d4c_0    conda-forge
ipython_genutils          0.2.0                      py_1    conda-forge
jedi                      0.16.0                   py38_0    conda-forge
jpeg                      9c                h14c3975_1001    conda-forge
json-c                    0.13.1            h14c3975_1001    conda-forge
jupyter_client            5.3.4                    py38_1    conda-forge
jupyter_core              4.6.1                    py38_0    conda-forge
kealib                    1.4.10            h58c409b_1005    conda-forge
krb5                      1.16.4               h2fd8d38_0    conda-forge
lame                      3.100             h14c3975_1001    conda-forge
ld_impl_linux-64          2.33.1               h53a641e_8    conda-forge
libblas                   3.8.0               14_openblas    conda-forge
libcblas                  3.8.0               14_openblas    conda-forge
libclang                  9.0.1           default_hde54327_0    conda-forge
libcurl                   7.65.3               hda55be3_0    conda-forge
libdap4                   3.20.4               hd3bb157_0    conda-forge
libedit                   3.1.20170329      hf8c457e_1001    conda-forge
libffi                    3.2.1             he1b5a44_1006    conda-forge
libgcc-ng                 9.2.0                h24d8f2e_2    conda-forge
libgd                     2.2.5             h307a58e_1007    conda-forge
libgdal                   3.0.4                h20022a4_0    conda-forge
libgfortran-ng            7.3.0                hdf63c60_5    conda-forge
libgomp                   9.2.0                h24d8f2e_2    conda-forge
libiconv                  1.15              h516909a_1005    conda-forge
libkml                    1.3.0             h4fcabce_1010    conda-forge
liblapack                 3.8.0               14_openblas    conda-forge
libllvm9                  9.0.1                hc9558a2_0    conda-forge
libnetcdf                 4.7.3           nompi_h9f9fd6a_101    conda-forge
libopenblas               0.3.7                h5ec1e0e_6    conda-forge
libpng                    1.6.37               hed695b0_0    conda-forge
libpq                     12.1                 hd9ab2ff_0    conda-forge
libsodium                 1.0.17               h516909a_0    conda-forge
libspatialite             4.3.0a            ha48a99a_1034    conda-forge
libssh2                   1.8.2                h22169c7_2    conda-forge
libstdcxx-ng              9.2.0                hdf63c60_2    conda-forge
libtiff                   4.1.0                hc3755c2_3    conda-forge
libuuid                   2.32.1            h14c3975_1000    conda-forge
libwebp                   1.0.2                h56121f0_5    conda-forge
libxcb                    1.13              h14c3975_1002    conda-forge
libxkbcommon              0.9.1                hebb1f50_0    conda-forge
libxml2                   2.9.10               hee79883_0    conda-forge
lz4-c                     1.8.3             he1b5a44_1001    conda-forge
ncurses                   6.1               hf484d3e_1002    conda-forge
netcdf4                   1.5.3                    pypi_0    pypi
nettle                    3.4.1             h1bed415_1002    conda-forge
nspr                      4.24                 he1b5a44_0    conda-forge
nss                       3.47                 he751ad9_0    conda-forge
numpy                     1.18.1           py38h95a1406_0    conda-forge
openh264                  1.8.0             hdbcaa40_1000    conda-forge
openjpeg                  2.3.1                h981e76c_3    conda-forge
openssl                   1.1.1d               h516909a_0    conda-forge
packaging                 20.1                       py_0    conda-forge
pandas                    1.0.0            py38hb3f55d8_0    conda-forge
pango                     1.42.4               ha030887_1    conda-forge
parso                     0.6.1                      py_0    conda-forge
pcre                      8.43                 he1b5a44_0    conda-forge
pexpect                   4.8.0                    py38_0    conda-forge
pickleshare               0.7.5                 py38_1000    conda-forge
pip                       20.0.2                   py38_1    conda-forge
pixman                    0.38.0            h516909a_1003    conda-forge
poppler                   0.67.0               h14e79db_8    conda-forge
poppler-data              0.4.9                         1    conda-forge
postgresql                12.1                 hc63931a_0    conda-forge
proj                      6.3.0                hc80f0dc_0    conda-forge
prompt_toolkit            3.0.3                      py_0    conda-forge
pthread-stubs             0.4               h14c3975_1001    conda-forge
ptyprocess                0.6.0                   py_1001    conda-forge
pygments                  2.5.2                      py_0    conda-forge
pygmt                     0.0.1a0+69.g320a728          pypi_0    pypi
pyparsing                 2.4.6                      py_0    conda-forge
python                    3.8.1                h357f687_2    conda-forge
python-dateutil           2.8.1                      py_0    conda-forge
pytz                      2019.3                     py_0    conda-forge
pyzmq                     18.1.1           py38h1768529_0    conda-forge
qt                        5.12.5               hd8c4c69_1    conda-forge
readline                  8.0                  hf8c457e_0    conda-forge
setuptools                45.1.0                   py38_0    conda-forge
six                       1.14.0                   py38_0    conda-forge
sqlite                    3.30.1               hcee41ef_0    conda-forge
tbb                       2018.0.5             h2d50403_0    conda-forge
tiledb                    1.7.0                hcde45ca_2    conda-forge
tk                        8.6.10               hed695b0_0    conda-forge
tornado                   6.0.3            py38h516909a_0    conda-forge
traitlets                 4.3.3                    py38_0    conda-forge
tzcode                    2019a             h516909a_1002    conda-forge
wcwidth                   0.1.8                      py_0    conda-forge
wheel                     0.34.2                   py38_0    conda-forge
x264                      1!152.20180806       h14c3975_0    conda-forge
xarray                    0.15.0                     py_0    conda-forge
xerces-c                  3.2.2             h8412b87_1004    conda-forge
xorg-kbproto              1.0.7             h14c3975_1002    conda-forge
xorg-libice               1.0.10               h516909a_0    conda-forge
xorg-libsm                1.2.3             h84519dc_1000    conda-forge
xorg-libx11               1.6.9                h516909a_0    conda-forge
xorg-libxau               1.0.9                h14c3975_0    conda-forge
xorg-libxdmcp             1.1.3                h516909a_0    conda-forge
xorg-libxext              1.3.4                h516909a_0    conda-forge
xorg-libxrender           0.9.10            h516909a_1002    conda-forge
xorg-libxt                1.2.0                h516909a_0    conda-forge
xorg-renderproto          0.11.1            h14c3975_1002    conda-forge
xorg-xextproto            7.3.0             h14c3975_1002    conda-forge
xorg-xproto               7.0.31            h14c3975_1007    conda-forge
xz                        5.2.4             h14c3975_1001    conda-forge
zeromq                    4.3.2                he1b5a44_2    conda-forge
zlib                      1.2.11            h516909a_1006    conda-forge
zstd                      1.4.4                h3b9ef0a_1    conda-forge

Any thoughts on what might be going on? Thanks!

@welcome
Copy link

welcome bot commented Feb 4, 2020

👋 Thanks for opening your first issue here! Please make sure you filled out the template with as much detail as possible. You might also want to take a look at our contributing guidelines and code of conduct.

@tjcrone
Copy link
Author

tjcrone commented Feb 4, 2020

Is it possible that GMT cannot find the Ghostscript executable? I wonder if there is a way of passing the location of my Ghostscript executable to fig.show() as a kwarg?

(axial) jovyan@jupyter-tjcrone:~$ which gs
/home/jovyan/.conda/envs/axial/bin/gs

@tjcrone
Copy link
Author

tjcrone commented Feb 4, 2020

By hardcoding kwargs["G"] = '/home/jovyan/.conda/envs/axial/bin/gs' just after the following line:

kwargs = self._preprocess(**kwargs)
I was able to get pygmt working in my environment.

I'm happy to submit a PR that allows the location of the Ghostscript executable to be found by GMT. One way is to pass **kwargs to fig.show(), but I doubt this is the best way. Another way is to set another environment variable. Any thoughts on how to best approach this? Or is there already another solution that I do not know about? Thanks!

@seisman
Copy link
Member

seisman commented Feb 4, 2020

It's really weird. Your gs is in your PATH, and GMT should be able to find it without any extra settings.

@tjcrone
Copy link
Author

tjcrone commented Feb 4, 2020

I'm not sure what we see in the Jupyterlab terminal window is the environment seen by a notebook when using conda environments inside Jupyterlab.

@seisman
Copy link
Member

seisman commented Feb 4, 2020

Maybe you could try following steps:

  1. Open a terminal (not the Jupyterlab terminal)
  2. activate your conda environment (i.e. axial)
  3. Run python or ipython
  4. Run the example you mentioned and see if it works

@tjcrone
Copy link
Author

tjcrone commented Feb 4, 2020

Well, I am running this on Pangeo, which is built on a z2jh foundation using Kubernetes in the cloud. So opening a terminal separate from Jupyterlab isn't quite possible the way it would be if I was running all this locally. I'm switching to the conda environment using nb_conda_kernels. You are probably right that I just need to figure out how to set up my environment correctly.

We don't normally use/need conda environments on Pangeo, but I am unable to conda install gmt==6.0.0 on Pangeo because all sorts of conflicts and I decided to try inside a conda environment. I can at least install GMT, but now we have environment issues. Another solution is to figure out why gmt==6.0.0 cannot be installed on Pangeo.

@tjcrone
Copy link
Author

tjcrone commented Feb 4, 2020

@ocefpaf, hope you are doing well. One potential solution to the issue here is figuring out how to conda install gmt==6.0.0 on Pangeo. Any suggestions on how to make this work?

@ocefpaf
Copy link

ocefpaf commented Feb 4, 2020

@ocefpaf, hope you are doing well. One potential solution to the issue here is figuring out how to conda install gmt==6.0.0 on Pangeo. Any suggestions on how to make this work?

Sure. I can help you debug that. Can you open an issue outside of pygmt, probably in a pangeo repo, so we can track this? I will need to check the current environment.yaml file pangeo. Can you point me to the one you are using? (Sorry, at this point I should know that already.)

(It may be as simple as a re-render/rebuild of gmt. But probably not that easy ;-p)

@tjcrone
Copy link
Author

tjcrone commented Feb 4, 2020

Thank you for the quick response @ocefpaf! New issue here: pangeo-data/pangeo-cloud-federation#525

@tjcrone
Copy link
Author

tjcrone commented Feb 6, 2020

Working with @ocefpaf, I figured out how to install gmt=6 using conda inside Pangeo without a conda env, and this configuration issue was resolved. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants