I am using Revit 2024.
I just installed pyRevit_5.0.0.25034_admin_signed while removing the previous non-admin version.
I run my existing script successfully, but the popup window showed the following:
I ran the model on an Ubuntu server shared to Windows using samba.
The python and pyRevit codes are on Windows 10 or 11 (two computers tested).
I uninstalled all versions of python and pyRevit on my Windows computer, and reinstalled again.
python-3.13.2-amd64.exe
pyRevit_5.0.0.25034_admin_signed.exe
I ran one short script with print out to pyRevit’s pop-up window. That message did not appear.
I ran one long script with no print out to pyRevit’s pop-up window. Windows’ command prompt window flashed in and out quickly. Unable to see that message.
I installed pyRevit_CLI_5.0.0.25034_admin_signed and ran the two scripts again.
The short script did not give that message.
The long script gave that message on pyRevit’s pop-up window.
The long script did not use pyrevit.revit.query.
The issue can be reported.
The long script has more than 1000 lines and I do not know which portion I should take to test.
It is a private network with the Ubuntu serving as a file server.
I need to run openpyxl. I do not know how to use that with pyRevit’s internal engine. I therefore installed CPyhton to put openpyxl there with success. I have tried Ironpython but do not know how to put openpyxl there. This probably is a side issue but any direction on this aspect is welcome.
pyRevit installation guides on various websites do tell to install Python, instead of telling how to use the internal engine.
I run the scripts through Revit menu items set up using pyRevit.
pyRevbit installs various Python engines.
Check your C:\Users%USERNAME%\AppData\Roaming\pyRevit-Master\bin\engines
You probably have your python installed elsewhere and pyRevit isn’t looking at that particular engine.
So ether configure pyRevit to look at your python installed engine (harder). Or install your openpyxl to the pyRevit python engine. (Simpler. Best to use the distributed engine.)
You can change engines under pyRevit > Settings > Core Settings > Engine.
Note that the cpython engine can be seleted per script with the #! python3 declaration in the opening line of the script.
I use Visual Studio Code and Python 3.13.2 to compose the scripts and begin them with #! python3. When running the scripts, the engine used is actually Python 3.12.3 provided by pyRevit.
I also use the following to look up and use openpyxl successfully:
import os
username = os.getlogin()
import sys
# give paths to user installed packages
sys.path.append("C:\\Users\\" + username + "\\AppData\\Local\\Programs\\Python\\Python313\\Lib\\site-packages")
import openpyxl
from openpyxl import Workbook # type: ignore
from openpyxl import load_workbook # type: ignore
What exactly are the harder and simpler ways mentioned by you?
I wouldn’t mix 3.13 and 3.12 as you are doing in your python path. I’m not sure there are version issues, but there could be. Best to get your packages installed under pyRevit’s 3.12.
But let’s back up…
Your first post shows an error with a bad escape sequence. have you corrected that? Look at your strings: " \ " isn’t a proper string. \ is a reserved character and needs to be escaped as “\\”
Not sure if that was a forum editor issue or you really have just “\”
I have moved from c# and microsoft.office.interop.excel to python and openpyxl, and spent many hours to learn openpyxl to read and write. I do not want to try xlrd and xlrswriter unless really necessary.
There are some features available in CPython 3.12 but not IPY2712. To use IPY2712, I have to find the equivalent workaround. But, more importantly, I still have to learn how to use openpyxl with IPY2712. A question I raised separately.
I may try to downgrade to use Cpython 3.12. I understand that 3.13 is used to help write the codes only, but the actual execution uses 3.12, and I presume that so long as I do not use features newly added to 3.13, there should not be a problem.
Back to the first post. The bad escape sequence has not been corrected yet. My codes do not have "\ " – a “\” followed by a space. This is not a forum editor issue. My codes use “\\”.
I have now found the line of code which causes that error message: from pyrevit import revit, DB
Strangely, the error message appears only when running the script for the first time after newly opening Revit and the model. It does not appear when running subsequently.
I said previously that the error message appeared when I ran my long script but not my short script. Probably, I ran the long script first.
The line of code (1181) from pyRevit query.py is :
def get_rvt_link_doc_name(rvtlink_instance):
"""
Retrieves the name of the Revit link document from the given Revit link instance.
Args:
rvtlink_instance: The Revit link instance from which to extract the document name.
Returns:
str: The name of the Revit link document, without the file extension and any directory paths.
"""
return get_name(rvtlink_instance).split(" \ ")[0].split(".rvt")[0]
Does your file have links and is your app working with them?
If so - look at the file name and path going into this def.
The error message did not appear on subsequent runs.
Previously my custom extension directories had a space within the filename but not immediately after “\”. The same problems arose after I removed the space.