Output print using CPython

The following script suggested by pyRevit Document works:

from pyrevit import script
output = script.get_output()
output.print_md('# My Title')
output.print_md('**Bold message**')

But gives the following error if starting with “#! python3”:

**CPython Traceback:**
cannot import name 'Callable' from 'collections' (C:\Program Files\pyRevit-Master\bin\cengines\CPY3123\python312.zip\collections\__init__.pyc)

pyRevitLabs.PythonNet
File "C:\Program Files\pyRevit-Master\pyrevitlib\pyrevit\coreutils\pyutils.py", line 13, in <module>
from collections import OrderedDict, Callable #pylint: disable=E0611

What should be the equivalent scripts for CPython?

This what you expected?

#! cpython3
from pyrevit import script
output = script.get_output()
output.print_md('# My Title')
output.print_md('**Bold message**')

This is 5.0.1 (Haven’t installed 5.1.0 yet…)
Note: I had a type previously - pythin3 - so the code completed without error under IronPython:"

I used pyRevit 5.0.0 with Revit 2024. I have now uninstalled 5.0.0, installed 5.0.1, updated pyRevit, closed and opened Revit, updated pyRevit again, and run the above script beginning with #! python3 or #! cpython3. Still getting the following error:

CPython Traceback:
cannot import name ‘Callable’ from ‘collections’ (C:\Program Files\pyRevit-Master\bin\cengines\CPY3123\python312.zip\collections_init_.pyc)

pyRevitLabs.PythonNet
File “C:\Program Files\pyRevit-Master\pyrevitlib\pyrevit\coreutils\pyutils.py”, line 13, in
from collections import OrderedDict, Callable #pylint: disable=E0611
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

I meant “reload pyRevit again”.

I have done the same for pyRevit 5.1.0. Same result.

Copilot has suggested “collections” should be revised to “collections.abc” starting from CPython 3.3. Is it relevant?

What engine are you using? 5.0.1 ships with 3.12…3 as does pyRevit 5.1.0. Did you install 3.3?

pyRevit uses 3.12.3 as seen in the above error message, though I use 3.13.2 for writing scripts.

Python 3.12.3:

from collections import OrderedDict
from collections.abc import Callable

IronPython 3.4

from collections import OrderedDict, Callable

Looks like this should be flagged over at GitHub for follow-up. (Done.)
pyRevit is importing that under IronPython and all is fine.
If you try and load pyutils.py manually with cpython, you get the error.