IntelliJ IDEA issue: xarray & pyparsing exception on import

93 views Asked by At

This has something to do with the IntelliJ IDEA 2017.1.1 IDE. I do not get the following issue when executing my code via the command line.

===========================================================================

Python version: 3.6.1
xarray version: 0.9.6
pandas version: 0.20.3
numpy version: 1.12.1

I, for the first time, would like to use xarray.

I imported the module (no problem here) and then, without even using the module, ran my code. For example:

import xarray as xr

def something():
    print("doing something...")

something()

This immediately throws an exception when I run it:

Exception ignored in: at 0x05A287B0> Traceback (most recent call last): File "C:\Program Files (x86)\Python36-32\lib\site-packages\pyparsing.py", line 160, in _generatorType = type((y for y in range(1))) SystemError: error return without exception set

If I delete the import xarray as xr and rerun the code, I get no exception. From the exception message, it looks like something called pyparsing.py

Any ideas?

1

There are 1 answers

1
PaulMcG On

pyparsing is probably installed as a dependency from some other package. I have run the pyparsing unit tests on both Python 3.6.1 and 3.6.2 (as well as most other popular Python versions back to 2.6) without any error.

I suspect that something in your environment is defining range to be something other than the normal builtin range method, and this is then causing the pyparsing code to fail.

I will fix this in pyparsing, to replace range(1) with just an empty list, which should give the same results for pyparsing, but without the susceptibility to being overwritten by a monkeypatch to range.

In the meantime, try explicitly importing pyparsing before importing xarray, or anything else for that matter. A simple import pyparsing should do.