Skip to content

[Bug]: C# Loader: CPython Traceback: No module named 'pyrevit' #2999

@tay0thman

Description

@tay0thman

✈ Pre-Flight checks

  • I don't have SentinelOne antivirus installed (see above for the solution)
  • I have searched in the issues (open and closed) but couldn't find a similar issue
  • I have searched in the pyRevit Forum for similar issues
  • I already followed the installation troubleshooting guide thoroughly
  • I am using the latest pyRevit Version

🐞 Describe the bug

testing todays built with the C# Loader,
Running a test CPython script, it seems the loader can't find the pyrevitlib assemblies.
I had to manually inject the existing path into sys.path then import pyrevit.

⌨ Error/Debug Message

CPython Traceback:
No module named 'pyrevit'

♻️ To Reproduce

No response

⏲️ Expected behavior

the way to solve it:


try:
    import pyrevit
except ImportError:
    # 1. Find the path that contains the CPython Engine
    engine_path = next((p for p in sys.path if "pyRevit-Master" in p and "cengines" in p), None)
    
    if engine_path:
        # 2. Derive the root 'pyrevitlib' folder
        root_path = engine_path.split(r"\bin")[0]
        lib_path = os.path.join(root_path, "pyrevitlib")
        site_path = os.path.join(root_path, "site-packages")

        # 3. Inject into sys.path
        if os.path.exists(lib_path) and lib_path not in sys.path:
            sys.path.append(lib_path)
        if os.path.exists(site_path) and site_path not in sys.path:
            sys.path.append(site_path)

🖥️ Hardware and Software Setup (please complete the following information)

5.3.1.26008+2214-wip:3123:2025.4.40

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugBug that stops user from using the tool or a major portion of pyRevit functionality [class]

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions