OceanParcels / Parcels

Main code for Parcels (Probably A Really Computationally Efficient Lagrangian Simulator)
https://www.oceanparcels.org
MIT License
295 stars 136 forks source link

problem adding custom kernels (compatibility with python 3.8?) #691

Closed ignasivalles closed 4 years ago

ignasivalles commented 4 years ago

Dear parcels crew

Just in case you're not aware... after updating parcels my script failed when I was adding my custom kernels:

kernels = AdvectionRK4_3D + sampT + sampS +deleteout
pset.execute(kernels, ...)

where sampT, sampS and deleteout are f(particle, fieldset, time)

the error message was:

Traceback (most recent call last):
  File "run_MOCBOX_forward.py", line 171, in <module>
    kernels = AdvectionRK4_3D+sampT+sampS+deleteout
  File "/home/valles/miniconda3/envs/py3_parcels2/lib/python3.8/site-packages/parcels/kernel.py", line 383, in __add__
    return self.merge(kernel)
  File "/home/valles/miniconda3/envs/py3_parcels2/lib/python3.8/site-packages/parcels/kernel.py", line 376, in merge
    return Kernel(self.fieldset, self.ptype, pyfunc=None,
  File "/home/valles/miniconda3/envs/py3_parcels2/lib/python3.8/site-packages/parcels/kernel.py", line 115, in __init__
    exec(compile(py_mod, "<ast>", "exec"), user_ctx)
TypeError: required field "type_ignores" missing from Module

I found this: https://bugs.python.org/issue35894

... so at the moment the problem disappears when I downgrade the python version into 3.7, specifying it when I create the conda environment:

conda create -n py3_parcels -c conda-forge python=3.7 parcels

erikvansebille commented 4 years ago

Thanks for letting us know @ignasivalles! I hadn't encountered this issue myself yet, but good to be aware!

The python.org link suggests this is an issue with iphyton? Does this disappear if you don't run in jupyter/ipython but instead directly from the command line?

ignasivalles commented 4 years ago

I run directly the program from the command line $ python parcels_program.py and the problem It's still there. I don't know what may be, some kind of change regarding to AST module?. Are you running with python 3.8?

erikvansebille commented 4 years ago

This seems to have fixed for now by specifically forcing python-3.6 on http://oceanparcels.org/#installing