EconForge / dolo.py

Economic modelling in python
BSD 2-Clause "Simplified" License
98 stars 72 forks source link

`TypeError: required field "posonlyargs" missing from arguments' #174

Closed gboehl closed 4 years ago

gboehl commented 4 years ago

Running the introduction code from https://dolo.readthedocs.io/en/latest/installation.html#running-dolo gets me the following error:

YAMLLoadWarning:/usr/lib/python3.8/site-packages/dolo/compiler/recipes.py:20
    calling yaml.load() without Loader=... is deprecated, as the default Loader is
 unsafe. Please read https://msg.pyyaml.org/load for full details.
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-1-070f72b519e0> in <module>
----> 1 exec(compile(open("/home/gboehl/.owncloud/phd/lab/dolo.py").read(),"/home/
gboehl/.owncloud/phd/lab/dolo.py",'exec'))

~/.owncloud/phd/lab/dolo.py in <module>
      6
      7 from dolo import *                           # load the library
----> 8 model = yaml_import("https://raw.githubusercontent.com/EconForge/dolo/mast
er/examples/models/rbc.yaml")
      9                                              # import the model
     10 display(model)                               # display the model

/usr/lib/python3.8/site-packages/dolo/compiler/model_import.py in yaml_import(fnam
e, check, check_only)
     26     from dolo.compiler.model import Model
     27
---> 28     return Model(data)
     29     # from dolo.compiler.model import SymbolicModel
     30

/usr/lib/python3.8/site-packages/dolo/compiler/model.py in __init__(self, data)
    276         self.data = data
    277         self.model_type = 'dtcc'
--> 278         self.__compile_functions__()
    279         self.set_changed()
    280

/usr/lib/python3.8/site-packages/dolo/compiler/model.py in __compile_functions__(s
elf)
    328
    329             fff = get_factory(self, funname)
--> 330             fun, gufun = make_method_from_factory(
    331                 fff, vectorize=True, debug=debug)
    332             n_output = len(fff.content)

/usr/lib/python3.8/site-packages/dolang/function_compiler.py in make_method_from_f
actory(fff, vectorize, use_file, debug)
     71         signature = None
     72
---> 73     fun = eval_ast(mod)
     74
     75     from numba import jit, guvectorize

/usr/lib/python3.8/site-packages/dolang/function_compiler.py in eval_ast(mod)
    108     name = mod.body[0].name
    109     mod = ast.fix_missing_locations(mod)
--> 110     code = compile(mod, '<string>', 'exec')
    111     exec(code, context, context)
    112     fun = context[name]

TypeError: required field "posonlyargs" missing from arguments

System running Arch Linux & Python 3.8 (are you only supporting 2.7?)

albop commented 4 years ago

Thanks @gboehl for filling up the bug. We are actually compatible with python>=3.6, but your bug suggests it is <3.8. This bug probably comes from the generated code in 3.8 which does not seem to be compatible with python3.8 AST. This is a dolang issue: https://github.com/EconForge/Dolang.jl/issues/62

raina126 commented 4 years ago

i have the same issue usually,i always don't know how to solve the problem

albop commented 4 years ago

That one is caused by a change in the tree representation of code in Python 3.8. It is actually a dolang bug, which has been fixed in dolang.py/master. You can either wait for a release (probably by the end of the week) or try to install the master version from here: https://github.com/EconForge/dolang.py

raina126 commented 4 years ago

First:i used the version 3.8.2 of the python and the version 2020.1 of the pycharm,Can i changes to the version3.8.1 or 3.7.x of the python to solves this problam?Second:where the place i put the dolang.py\master down?

At 2020-04-22 05:27:25, "Pablo Winant" notifications@github.com wrote:

That one is caused by a change in the tree representation of code in Python 3.8. It is actually a dolang bug, which has been fixed in dolang.py/master. You can either wait for a release (probably by the end of the week) or try to install the master version from here: https://github.com/EconForge/dolang.py

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or unsubscribe.

albop commented 4 years ago

This should now be fixed with up-to-date versions of dolang and dolo released today on PyPI.