Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem importing dolo " 'charmap' codec can't decode byt" #223

Open
marcdelabarrera opened this issue Feb 18, 2021 · 6 comments
Open

Problem importing dolo " 'charmap' codec can't decode byt" #223

marcdelabarrera opened this issue Feb 18, 2021 · 6 comments

Comments

@marcdelabarrera
Copy link

I have installed dolo (0.4.9.14) on a Windows but when I import dolo, the following error arises:

~\anaconda3\lib\encodings\cp1252.py in decode(self, input, final)
     21 class IncrementalDecoder(codecs.IncrementalDecoder):
     22     def decode(self, input, final=False):
---> 23         return codecs.charmap_decode(input,self.errors,decoding_table)[0]
     24 
     25 class StreamWriter(Codec,codecs.StreamWriter):

UnicodeDecodeError: 'charmap' codec can't decode byte 0x9d in position 1179: character maps to <undefined>

Any idea why this might be happening?

@albop
Copy link
Member

albop commented Feb 18, 2021 via email

@marcdelabarrera
Copy link
Author

Thank you for quick reply Pablo. I am using anaconda on a windows, with Pyhon 3.7.6. I don't want to get back to Dynare!

Also, I tried to install it on Google Colab, I could import it, but when I try to run your first example

model = yaml_import("https://raw.githubusercontent.com/EconForge/dolo/master/examples/models/rbc.yaml")

I get the error

/usr/local/lib/python3.6/dist-packages/dolo/linter.py in check_definitions(data)
    275 
    276     new_definitions = dict()
--> 277     for k, v in definitions.items():
    278         pos = definitions.lc.data[k]
    279         if k in known_symbols:

AttributeError: 'LiteralScalarString' object has no attribute 'items'

@albop
Copy link
Member

albop commented Feb 19, 2021

Hi @marcdelabarrera,
There are two different issues here:

  • Google Colab is using python 3.6, and dolo requires python >=3.7 . We have dropped compatibility a while ago, and unless there is a big demand for it (like a class using it for teaching), there are no plans to go back
    • there are other options to use dolo without any installation: mybinder and gitpod are two of them. We should add it to the documentation.
  • As for the error in the first message, if you can still replicate it, would you mind pasting the full traceback ? I would suppose one file, is incorrectly decoded under windows, and it would help to know which one.

@cohenimhuji
Copy link

cohenimhuji commented Feb 28, 2021

Hi,
i installed dolo (dolo-0.4.9.14.dist-info) but didn't succed to import it
[i use python 3.7.4 64-bit (conda) using VS-Code with Jupyter extention]
here is my log:

UnicodeDecodeError Traceback (most recent call last)
in
----> 1 import dolo

~\Anaconda3\lib\site-packages\dolo_init_.py in
1 from dolo.version import version_info, version
2
----> 3 import dolang
4
5 from dolo.config import *

~\Anaconda3\lib\site-packages\dolang_init_.py in
2 from dolang.yaml_tools import yaml
3
----> 4 from dolang.grammar import parse_string
5 from dolang.grammar import (
6 stringify,

~\Anaconda3\lib\site-packages\dolang\grammar.py in
27 DATA_PATH = os.path.join(DIR_PATH, "grammar.lark")
28
---> 29 grammar_0 = open(DATA_PATH, "rt").read()
30
31

~\Anaconda3\lib\encodings\cp1252.py in decode(self, input, final)
21 class IncrementalDecoder(codecs.IncrementalDecoder):
22 def decode(self, input, final=False):
---> 23 return codecs.charmap_decode(input,self.errors,decoding_table)[0]
24
25 class StreamWriter(Codec,codecs.StreamWriter):

UnicodeDecodeError: 'charmap' codec can't decode byte 0x9d in position 1179: character maps to

@TimMunday
Copy link

I'm using windows, changing line 29 in grammar.py to:

grammar_0 = open(DATA_PATH, "rt", encoding='utf-8').read()

solves the problem as now the encoding is specified, otherwise it seems windows is confused.

Can submit a PR if needed

@albop
Copy link
Member

albop commented Jun 24, 2021 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants