Search code examples
eclipsepandaspydev

PyDev in Debug mode: NameError: dict_pop when importing pandas or xarray


I'm running code to read data from a NetCDF file from a URL with xarray. When I run this code in Eclipse/PyDev in debug mode I am seeing errors that don't happen when launching as a normal Python run or from the command line or as cells of a Jupyter notebook.

I get the following error when I include an import xarray in my code:

 NameError: name 'dict_pop' is not defined

Full stack trace looks like this:

pydev debugger: starting (pid: 4004)
URL: https://www.ncei.noaa.gov/data/nclimgrid/nclimgrid_prcp.nc
Traceback (most recent call last):
  File "_pydevd_bundle\pydevd_cython_win32_35_64.pyx", line 741, in _pydevd_bundle.pydevd_cython_win32_35_64.PyDBFrame.trace_dispatch (_pydevd_bundle/pydevd_cython_win32_35_64.c:15515)
  File "_pydevd_bundle\pydevd_cython_win32_35_64.pyx", line 254, in _pydevd_bundle.pydevd_cython_win32_35_64.PyDBFrame.do_wait_suspend (_pydevd_bundle/pydevd_cython_win32_35_64.c:5631)
  File "C:\User Programs\eclipse\neon\plugins\org.python.pydev_5.9.0.201708101613\pysrc\pydevd.py", line 764, in do_wait_suspend
    self._activate_mpl_if_needed()
  File "C:\User Programs\eclipse\neon\plugins\org.python.pydev_5.9.0.201708101613\pysrc\pydevd.py", line 415, in _activate_mpl_if_needed
    activate_function = dict_pop(self.mpl_modules_for_patching, module)
NameError: name 'dict_pop' is not defined
2017-08-16  15:25:06 ERROR Failed to complete ERROR
Traceback (most recent call last):
  File "C:\home\git\indices_github\process_xarray.py", line 27, in <module>
    ncdata = url.read()
  File "C:\home\git\indices_github\process_xarray.py", line 27, in <module>
    ncdata = url.read()
  File "_pydevd_bundle\pydevd_cython_win32_35_64.pyx", line 982, in _pydevd_bundle.pydevd_cython_win32_35_64.SafeCallWrapper.__call__ (_pydevd_bundle/pydevd_cython_win32_35_64.c:19346)
  File "_pydevd_bundle\pydevd_cython_win32_35_64.pyx", line 498, in _pydevd_bundle.pydevd_cython_win32_35_64.PyDBFrame.trace_dispatch (_pydevd_bundle/pydevd_cython_win32_35_64.c:18639)
  File "_pydevd_bundle\pydevd_cython_win32_35_64.pyx", line 750, in _pydevd_bundle.pydevd_cython_win32_35_64.PyDBFrame.trace_dispatch (_pydevd_bundle/pydevd_cython_win32_35_64.c:15669)
  File "_pydevd_bundle\pydevd_cython_win32_35_64.pyx", line 741, in _pydevd_bundle.pydevd_cython_win32_35_64.PyDBFrame.trace_dispatch (_pydevd_bundle/pydevd_cython_win32_35_64.c:15515)
  File "_pydevd_bundle\pydevd_cython_win32_35_64.pyx", line 254, in _pydevd_bundle.pydevd_cython_win32_35_64.PyDBFrame.do_wait_suspend (_pydevd_bundle/pydevd_cython_win32_35_64.c:5631)
  File "C:\User Programs\eclipse\neon\plugins\org.python.pydev_5.9.0.201708101613\pysrc\pydevd.py", line 764, in do_wait_suspend
    self._activate_mpl_if_needed()
  File "C:\User Programs\eclipse\neon\plugins\org.python.pydev_5.9.0.201708101613\pysrc\pydevd.py", line 415, in _activate_mpl_if_needed
    activate_function = dict_pop(self.mpl_modules_for_patching, module)
NameError: name 'dict_pop' is not defined
Traceback (most recent call last):
  File "C:\User Programs\eclipse\neon\plugins\org.python.pydev_5.9.0.201708101613\pysrc\pydevd.py", line 1621, in <module>
    main()
  File "C:\User Programs\eclipse\neon\plugins\org.python.pydev_5.9.0.201708101613\pysrc\pydevd.py", line 1615, in main
    globals = debugger.run(setup['file'], None, None, is_module)
  File "C:\User Programs\eclipse\neon\plugins\org.python.pydev_5.9.0.201708101613\pysrc\pydevd.py", line 1022, in run
    pydev_imports.execfile(file, globals, locals)  # execute the script
  File "C:\User Programs\eclipse\neon\plugins\org.python.pydev_5.9.0.201708101613\pysrc\_pydev_imps\_pydev_execfile.py", line 25, in execfile
    exec(compile(contents+"\n", file, 'exec'), glob, loc)
  File "C:\home\git\indices_github\process_xarray.py", line 27, in <module>
    ncdata = url.read()
  File "C:\home\git\indices_github\process_xarray.py", line 27, in <module>
    ncdata = url.read()
  File "_pydevd_bundle\pydevd_cython_win32_35_64.pyx", line 982, in _pydevd_bundle.pydevd_cython_win32_35_64.SafeCallWrapper.__call__ (_pydevd_bundle/pydevd_cython_win32_35_64.c:19346)
  File "_pydevd_bundle\pydevd_cython_win32_35_64.pyx", line 498, in _pydevd_bundle.pydevd_cython_win32_35_64.PyDBFrame.trace_dispatch (_pydevd_bundle/pydevd_cython_win32_35_64.c:18639)
  File "_pydevd_bundle\pydevd_cython_win32_35_64.pyx", line 750, in _pydevd_bundle.pydevd_cython_win32_35_64.PyDBFrame.trace_dispatch (_pydevd_bundle/pydevd_cython_win32_35_64.c:15669)
  File "_pydevd_bundle\pydevd_cython_win32_35_64.pyx", line 741, in _pydevd_bundle.pydevd_cython_win32_35_64.PyDBFrame.trace_dispatch (_pydevd_bundle/pydevd_cython_win32_35_64.c:15515)
  File "_pydevd_bundle\pydevd_cython_win32_35_64.pyx", line 254, in _pydevd_bundle.pydevd_cython_win32_35_64.PyDBFrame.do_wait_suspend (_pydevd_bundle/pydevd_cython_win32_35_64.c:5631)
  File "C:\User Programs\eclipse\neon\plugins\org.python.pydev_5.9.0.201708101613\pysrc\pydevd.py", line 764, in do_wait_suspend
    self._activate_mpl_if_needed()
  File "C:\User Programs\eclipse\neon\plugins\org.python.pydev_5.9.0.201708101613\pysrc\pydevd.py", line 415, in _activate_mpl_if_needed
    activate_function = dict_pop(self.mpl_modules_for_patching, module)
NameError: name 'dict_pop' is not defined

I'm using recent/latest versions of xarray and pandas installed on Python 3.5.3 (Anaconda).

I get the same error with an 'import pandas' statement as well, so this may be pandas related instead since xarray depends upon pandas internally.

The packages are installed in Anaconda as shown below:

$ conda list pandas
# packages in environment at C:\home\Anaconda3:
#
pandas                    0.20.3                   py35_1    conda-forge

$ conda list xarray
# packages in environment at C:\home\Anaconda3:
#
xarray                    0.9.6                    py35_0    conda-forge

Again I can run this code with the imports of pandas and xarray with no issue from the command line and/or within a Jupyter notebook, this only happens when I launch the code in Eclipse/PyDev in debug mode (regular Python run works as expected).

Example Python code I'm using to test this:

import sys
import xarray as xr

if __name__ == '__main__':

    try:

        # get the command line arguments
        input_netcdf_url = sys.argv[1]
        ds = xr.open_dataset(input_netcdf_url)
                
    except:
    
        raise

What can I try next?


Solution

  • Upgrade to 5.9.2... this was one of the critical issues fixed witch prompted the new release.