Hello everyone,
I’m trying to use Python 3 with pyRevit, but it’s not working. Even basic functions like print
aren’t executing.
Here’s my setup and process:
- I use
#! python3
at the beginning of my code. - I’ve installed Python 3.8.5 to align with pyRevit’s CPython engine.
- I’ve set the
PYTHONPATH
for my modules.
Below are examples of the error messages I’m receiving:
error message for basic print function:
error message when using some of the modules, its usually the same. If I am trying import any modules it says:
No module named
__future__
CPython Traceback:
ModuleNotFoundError : No module named ‘future’
File “C:\Users\kubar\AppData\Roaming\pyRevit\Extensions\ČVUT.extension\ČVUT.tab\Predemolition.panel\New Material.pushbutton\pip install_script.py”, line 3, in
from rapidfuzz import fuzz
File “C:\Users\kubar\AppData\Local\Programs\Python\Python38\Lib\site-packages\rapidfuzz_init_.py”, line 5, in
from future import annotations
pyRevitLabs.PythonNet
v Python.Runtime.Runtime.CheckExceptionOccurred()
v Python.Runtime.PyScope.Exec(String code, IntPtr _globals, IntPtr _locals)
v Python.Runtime.PyScope.Exec(String code, PyDict locals)
v PyRevitLabs.PyRevit.Runtime.CPythonEngine.Execute(ScriptRuntime& runtime)
here is the code I am using to test rapidfuzz module:
#! python3
from rapidfuzz import fuzz
from rapidfuzz import process
str1 = "Hello, world!"
str2 = "Hello, world!!!"
similarity = fuzz.ratio(str1, str2)
print(f"Similarity between '{str1}' and '{str2}': {similarity}%")
choices = ["Hello, world!", "Hello, there!", "Goodbye, world!"]
best_match = process.extractOne("Hello, world!!!", choices)
print(f"Best match: '{best_match[0]}' with similarity {best_match[1]}%")
all_matches = process.extract("Hello, world!!!", choices)
for match in all_matches:
print(f"Match: '{match[0]}' with similarity {match[1]}%")