g-battaglia / kerykeion

Data driven Astrology 💫
Kerykeion is a python library for astrology. It can generate SVG charts and extract all data about a birthchart, a synastry chart and a transit chart.
https://kerykeion.net
GNU Affero General Public License v3.0
297 stars 103 forks source link

Issue with Generating SVG chart example #83

Closed javonnii closed 1 year ago

javonnii commented 1 year ago

from kerykeion import AstrologicalSubject, KerykeionChartSVG

first = AstrologicalSubject("Jack", 1990, 6, 15, 15, 15, "Roma") second = AstrologicalSubject("Jane", 1991, 10, 25, 21, 00, "Roma")

Set the type, it can be Natal, Synastry or Transit

name = KerykeionChartSVG(first, chart_type="Synastry", second_obj=second) name.makeSVG() print(len(name.aspects_list))

> Generating kerykeion object for Jack...

> Generating kerykeion object for Jane...

> Jack birth location: Roma, 41.89193, 12.51133

> SVG Generated Correctly

> 38

ERROR:


UnicodeDecodeError Traceback (most recent call last) ~\AppData\Local\Temp/ipykernel_8032/3053983563.py in 6 # Set the type, it can be Natal, Synastry or Transit 7 ----> 8 name = KerykeionChartSVG(first, chart_type="Synastry", second_obj=second) 9 name.makeSVG() 10 print(len(name.aspects_list))

~\AppData\Roaming\Python\Python39\site-packages\kerykeion\charts\kerykeion_chart_svg.py in init(self, first_obj, chart_type, second_obj, new_output_directory, new_settings_file) 73 self.full_width = 1200 74 ---> 75 self.parse_json_settings(new_settings_file) 76 self.chart_type = chart_type 77

~\AppData\Roaming\Python\Python39\site-packages\kerykeion\charts\kerykeion_chart_svg.py in parse_json_settings(self, settings_file) 280 Parse the settings file. 281 """ --> 282 settings = get_settings_dict(settings_file) 283 284 language = settings["general_settings"]["language"]

~\AppData\Roaming\Python\Python39\site-packages\kerykeion\settings\kerykeion_settings.py in get_settings_dict(new_settings_file) 217 logger.debug(f"Kerykeion config file path: {settings_file}") 218 with open(settings_file, "r") as f: --> 219 settings_dict = load(f) 220 221 return settings_dict

C:\ProgramData\Anaconda3\lib\json__init__.py in load(fp, cls, object_hook, parse_float, parse_int, parse_constant, object_pairs_hook, **kw) 291 kwarg; otherwise JSONDecoder is used. 292 """ --> 293 return loads(fp.read(), 294 cls=cls, object_hook=object_hook, 295 parse_float=parse_float, parse_int=parse_int,

C:\ProgramData\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 0x81 in position 2455: character maps to

g-battaglia commented 1 year ago

Hi, what version of kerykeiona are you using? This issue should have been already fixed in the last update. I can't reproduce it but the issue should be in the file kerykeion_chart_svg.py

At line 1528

        with open(self.chartname, "w", encoding="utf-8", errors="ignore") as output_file:
            output_file.write(self.template)

Or at line 1509

        with open(self.xml_svg, "r", encoding="utf-8", errors="ignore") as output_file:
            f = open(self.xml_svg)
            template = Template(f.read()).substitute(td)

Check if your version is 4.1.1, if it is try changing the encoding type in the line above and pleas report if you fix the problem.

javonnii commented 1 year ago

Yep, that fixes it! Thank You!