Technical Blog‎ > ‎

Error when installing GSAS-II: matplotlib cannot import name cbook

posted Oct 19, 2018, 10:45 PM by Jingshan Du   [ updated Oct 23, 2018, 11:47 AM ]
GSAS-II is a fantastic crystallography package developed by the ANL written in python:

During installation, you will find that the package itself cannot be set up properly. When running its, you will see the following error:
Sorry, this version of Python cannot be used
for GSAS-II. It is missing the following package(s):
Please install these package(s) and try running this again.
Showing first error:
Traceback (most recent call last):
  File "GSASII\", line 187, in <module>
    exec('import '+pkg)
  File "<string>", line 1, in <module>
  File "C:\Miniconda2\lib\site-packages\matplotlib\", line 124, in <module>
    from . import cbook
ImportError: cannot import name cbook
This is simply the newer matplotlib versions breaks the code (misteriously). I searched on the web for a while and finally found some other people encountering similar problems with some other packages ( The solution is simple: downgrading the matplotlib to 2.0.2 by running:
conda install matplotlib=2.0.2
Note that I tested both 2.2.x and 2.1.x, and neither worked. 2.0.2 is the highest version that will run GSAS-II.

Update (10/23/2018)

I also found that the recent wxpython version 4.0.x has some problems working with GSAS-II. I downgraded to the classic wxpython 3.0 and now it works fine.