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

Workaround for PyGMT on Windows #431

Closed
seisman opened this issue May 17, 2020 · 6 comments
Closed

Workaround for PyGMT on Windows #431

seisman opened this issue May 17, 2020 · 6 comments
Labels
documentation Improvements or additions to documentation
Milestone

Comments

@seisman
Copy link
Member

seisman commented May 17, 2020

Description of the problem

We have several reported issues saying that pygmt can't load the GMT library on Windows, e.g. #46, #285, #353.

Actually, the description of the issues is inaccurate. PyGMT works well with the GMT official installers (i.e., gmt-6.0.0-win64.exe), but doesn't work with the gmt conda package on Windows. We're working on a fix in PR #313, but currently, it's still not clear why the conda windows package is special, and it may take a long time to make it work (it's almost solved, see #434 and GenericMappingTools/gmt#3353).


Update on May 22, 2020

PyGMT v0.1.1 works perfectly on Windows. No workaround is needed.

Please follow the latest install instructions.


Update on May 20, 2020:

We finally find out why PyGMT crashes with the GMT conda package on Windows. The issue was fixed in #434.

Currently, Windows users can install the PyGMT master branch:

pip install https://github.com/GenericMappingTools/pygmt/archive/master.zip

so that import pygmt will work. We will release PyGMT v0.1.1 in the coming days on PyPI and conda-forge to include the new fixes.

and add one environmental variable:

  • GMT_LIBRARY_PATH: path to the gmt.dll path, e.g., C:\Miniconda\envs\pygmt\Library\bin
  • GMT_SHAREDIR: path to the GMT's share directory, e.g., C:\Miniconda\envs\pygmt\Library\share\gmt

More testing from Windows users are welcomed.


Posted on May 17, 2020.

The workaround below is still valid, but please follow the comment above.

For PyGMT users on Windows, the simplest workaround would be:

# configure conda to get packages from the conda-forge channel:
conda config --prepend channels conda-forge
# create a new conda environment
conda create --name pygmt python=3.6 pip numpy pandas xarray netcdf4 packaging 
# Activate the environment by running:
conda activate pygmt
# install pygmt
pip install pygmt
# download GMT installers and install it
...

note: currently, we can't use conda install pygmt on Windows, but it should be fixed later.

Perhaps also need to set the environmental variable GMT_LIBRARY_PATH to the gmt.dll library path, e.g., C:\Miniconda\envs\testing\Library\bin.

I just installed GMT and pygmt following the install instruction above and successfully made a simple plot.

I think this is easier than "building from source" or using "WSL" as suggested in our documentation (https://www.pygmt.org/latest/install.html), and we should recommend this way instead.

@weiji14 weiji14 added the documentation Improvements or additions to documentation label May 17, 2020
@weiji14 weiji14 pinned this issue May 17, 2020
@weiji14
Copy link
Member

weiji14 commented May 17, 2020

Ok, we should add this workaround to the documentation. Probably need to make a 0.1.1 release too otherwise it won't show up on pygmt.org/latest. And we'll need to have the windows conda package ready. Bit of a chicken and egg situation...

@seisman

This comment has been minimized.

@seisman
Copy link
Member Author

seisman commented May 19, 2020

Here are what we should do:

@seisman
Copy link
Member Author

seisman commented May 20, 2020

The conda GMT package was rebuilt in conda-forge/gmt-feedstock#94. Windows users no longer need to set the variable GMT_SHAREDIR.

@seisman
Copy link
Member Author

seisman commented May 20, 2020

As per the conda documentation:

For now, most DLLs are installed into (install prefix)\Library\bin. This path is added to os.environ["PATH"] for all Python processes, so that DLLs can be located, regardless of the value of the system's PATH environment variable.

PyGMT should be able to locate gmt.dll.


PREFIX\Library\bin is in the PATH, but ctypes.CDLL("gmt.dll") cannot find the library. However, ctypes.CDLL("gmt.dll", winmode=0) can, but winmode is new in Python 3.8.

@weiji14 weiji14 added this to the 0.1.x milestone May 20, 2020
@seisman
Copy link
Member Author

seisman commented May 22, 2020

PyGMT v0.1.1 is released. It's expected to work smoothly on Windows. No workaround is needed anymore.

@seisman seisman closed this as completed May 22, 2020
@seisman seisman unpinned this issue May 22, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

2 participants