connorferster/handcalcs

KeyErrors on import handcalcs.render

MJFraker opened this issue ยท 9 comments

Windows 11 machine, python 3.12 installed. Succesfully installed (I think) jupyterlab, handcalcs, and forallpeople; however, after opening the jupyter coding broweser and typing import handcalcs.render, i get a sereies of "KeyErrors":


KeyError Traceback (most recent call last)
Cell In[6], line 1
----> 1 import handcalcs.render

File ~\AppData\Local\Programs\Python\Python312\Lib\site-packages\handcalcs_init_.py:18
14 """
15 Render arithmetic calucations in Jupyter as though they were written by hand.
16 """
17 version = "1.6.5" #
---> 18 from .decorator import handcalc
19 from .global_config import set_option, save_config
21 all = ["handcalc"]

File ~\AppData\Local\Programs\Python\Python312\Lib\site-packages\handcalcs\decorator.py:6
4 from functools import wraps
5 import inspect
----> 6 import innerscope
7 from .handcalcs import LatexRenderer
10 def handcalc(
11 override: str = "",
12 precision: int = 3,
(...)
17 jupyter_display: bool = False,
18 ):

File ~\AppData\Local\Programs\Python\Python312\Lib\site-packages\innerscope_init_.py:3
1 import importlib.metadata
----> 3 from .core import bindwith, call, callwith, scoped_function
5 try:
6 version = importlib.metadata.version("innerscope")

File ~\AppData\Local\Programs\Python\Python312\Lib\site-packages\innerscope\core.py:39
16 NEW_CODE = (
17 bytes([dis.opmap["LOAD_GLOBAL"]])
18 + b"%b"
(...)
21 + bytes([dis.opmap["BUILD_TUPLE"], 3, dis.opmap["RETURN_VALUE"], 0])
22 )
23 else:
24 NEW_CODE = (
25 bytes([dis.opmap["LOAD_GLOBAL"]])
26 + b"%b"
27 + bytes(
28 [
29 dis.opmap["CACHE"],
30 0,
31 dis.opmap["CACHE"],
32 0,
33 dis.opmap["CACHE"],
34 0,
35 dis.opmap["CACHE"],
36 0,
37 dis.opmap["CACHE"],
38 0,
---> 39 dis.opmap["PRECALL"],
40 0,
41 dis.opmap["CACHE"],
42 0,
43 dis.opmap["CALL"],
44 0,
45 dis.opmap["CACHE"],
46 0,
47 dis.opmap["CACHE"],
48 0,
49 dis.opmap["CACHE"],
50 0,
51 dis.opmap["CACHE"],
52 0,
53 dis.opmap["LOAD_GLOBAL"],
54 ]
55 )
56 + b"%b"
57 + bytes(
58 [
59 dis.opmap["CACHE"],
60 0,
61 dis.opmap["CACHE"],
62 0,
63 dis.opmap["CACHE"],
64 0,
65 dis.opmap["CACHE"],
66 0,
67 dis.opmap["CACHE"],
68 0,
69 dis.opmap["BUILD_TUPLE"],
70 3,
71 dis.opmap["RETURN_VALUE"],
72 0,
73 ]
74 )
75 )
76 BUILTINS = set(dir(builtins))
79 def _get_globals_recursive(func, *, seen=None, isclass=False):

KeyError: 'PRECALL'

I'm having the same problem and according to the comments in my question "Python 3.12 has removed PRECALL from its bytecode instructions, so it's likely that the handcalcs package needs an update."

I'm having the same problem and according to the comments in my question "Python 3.12 has removed PRECALL from its bytecode instructions, so it's likely that the handcalcs package needs an update."

Thanks for the response!

Agreed. @eriknw it seems that there was a Python API breaking change affecting innerscope.

My bad for not testing the 3.12 release candidate. Should have seen it coming because of all the speed improvements planned for each upcoming Python release.

Thanks @raianerosa @MJFraker for raising this issue

eriknw commented

My bad for being slow! Been traveling too much... I'll try to get to this soon even if it's just a workaround to make 3.12 work.

I am facing the same issue while import handcalcs.render

Same problem, any updates regarding this topic?

Try updating to the latest innerscope. I just created a new release (0.7.0) that should hopefully resolve this issue.

I'm sorry for the delay! I've had lots of, uh, "adventures" lately, and I updated innerscope to try to avoid issues like this in the future.

This seems to work for me, thank you :)