Python pyRevit use depends on the scripting engine and installed configuration. pyRevit supports multiple Python engines, including IronPython 2.7.12, IronPython 3.4.2, and CPython 3.12.3 in supported configurations. Understanding which engine is active helps you choose compatible scripts and avoid common errors.
Python version compatibility is important for Revit automation, custom commands, and external libraries. Whether you are a beginner or an experienced developer, knowing the differences between Python 2 and Python 3 can help you build reliable scripts and maintain existing pyRevit extensions.
Python Version pyRevit Use?
pyRevit’s traditional default scripting engine is IronPython 2.7.12, which uses Python 2.7 syntax. It also provides IronPython 3.4.2 and CPython 3.12.3 in supported configurations. These engines offer different language features and compatibility characteristics, so the version your script uses matters when developing automation tools.
The important distinction is that pyRevit does not necessarily run every script through the same Python interpreter. The selected engine, script configuration, and installed pyRevit build determine how a command executes. Before writing or installing a script, identify the active engine rather than assuming that pyRevit always uses the latest version of Python.
IronPython and CPython Support
IronPython is a Python implementation designed to work with the .NET ecosystem. pyRevit has traditionally relied on IronPython because it provides a practical way to interact with Revit’s .NET-based API. Its default IronPython 2.7.12 engine is compatible with many established pyRevit scripts, although those scripts may require changes when moved to a different interpreter.
CPython is the standard implementation of Python and supports a broad ecosystem of third-party packages. pyRevit also offers CPython support in compatible configurations, but integration with Revit and pyRevit’s existing libraries can have limitations. IronPython 3.4.2 provides a Python 3-based alternative, though its compatibility with older scripts and some dependencies differs from IronPython 2.7.
Why the Installed Version Matters
Your installed pyRevit build determines which scripting engines are available and how they can be configured. Revit version compatibility, runtime requirements, and the way pyRevit was installed can also affect the engines that are usable in your environment. Therefore, two users may have different scripting options even when they are working with Revit.
This matters most when you download an extension, adapt an existing script, or install a Python package. A script designed for Python 3 may fail under IronPython 2.7, while a script relying on IronPython-specific behavior may not work correctly under CPython. Checking compatibility before making changes saves troubleshooting time and helps prevent unexpected errors.
Does pyRevit Use Python 2 or Python 3?
pyRevit can use both Python 2 and Python 3, depending on the selected engine and configuration. IronPython 2.7.12 uses Python 2 syntax, while IronPython 3.4.2 and CPython 3.12.3 use Python 3 syntax within their respective environments. This means the answer depends on which interpreter executes your particular command.
Python 2 reached the end of its official support life in 2020, so Python 3 is generally the better choice for new general-purpose Python development. However, a pyRevit project may still rely on established scripts written for IronPython 2.7. Before migrating to Python 3, check the script’s dependencies and compatibility with the target engine instead of assuming that changing interpreters will make everything work automatically.
Key Differences Between Python 2 and Python 3
Python 2 and Python 3 differ in several areas, including text handling, division behavior in some contexts, library availability, and supported syntax. For example, Python 3 supports f-strings, which provide a convenient way to insert values into strings. A script using Python 3-only syntax will not run unchanged under Python 2.7.
These differences can affect everyday Revit automation. A script that reads parameter values, creates reports, or processes project information may need adjustments when moved between engines. Understanding the language version helps you identify whether an error comes from your script’s logic, unsupported syntax, or an incompatible dependency.
IronPython vs. CPython in pyRevit
IronPython and CPython both allow developers to write Python scripts, but they use different implementations and have different strengths. IronPython is designed around .NET integration, which makes it particularly relevant to Revit automation. CPython provides access to the wider Python ecosystem, including libraries that may not be available for IronPython. However, access to a package does not automatically mean it will integrate smoothly with Revit.
The best engine depends on your project requirements, existing scripts, and the libraries you need. If you are maintaining established pyRevit tools, IronPython may be the simpler option. If your work depends on Python packages that require a modern CPython interpreter, CPython may be worth exploring, provided that your pyRevit build supports the required integration.
How IronPython Works
IronPython is a Python implementation that runs on the .NET platform. It enables scripts to interact with .NET assemblies and Revit API components, making it suitable for many common BIM automation tasks. The traditional pyRevit engine, IronPython 2.7.12, remains important because many existing extensions and scripts were developed around its behavior.
IronPython 3.4.2 offers Python 3 language compatibility, but it should not be treated as a drop-in replacement for every IronPython 2 script. Language differences, library availability, and changes in the interpreter can affect existing tools. Before switching engines, test important commands and confirm that their dependencies work in the new environment.
How CPython Works
CPython is the standard Python implementation used by most general-purpose Python projects. It supports modern language features and a large collection of third-party libraries for data processing, calculations, reporting, and other tasks. This can be useful when a Revit automation workflow requires capabilities beyond those provided by the default scripting environment.
In pyRevit, however, CPython integration has its own requirements and limitations. Communication with the Revit API depends on the supported integration layer, and some pyRevit functionality may behave differently from its IronPython counterpart. Developers should verify engine availability, dependency compatibility, and the specific requirements of their scripts before choosing CPython for a production workflow.
How to Check Which Python Version pyRevit Uses
The most reliable way to identify your Python version is to inspect the active scripting engine rather than relying only on the pyRevit version number. Installing a particular pyRevit release does not necessarily mean that every command will use the same interpreter. Your engine selection and script configuration are important parts of the process.
If you are troubleshooting an extension, check the engine it expects and compare it with the engine available in your current Revit session. Where supported, inspecting the interpreter’s version information from a test script can confirm which runtime actually executed the code. This is especially useful when an extension behaves differently across computers or Revit installations.
Check Your pyRevit Installation
Start by identifying your installed pyRevit build and reviewing its available engine settings. Look for the configured IronPython or CPython option and check whether the required runtime is available for your Revit session. The exact controls and options can vary between builds, so use the settings appropriate to your installation rather than following instructions written for an unrelated release.
You should also check whether the installed extension has its own scripting requirements. A tool may have been designed for IronPython 2.7 even if another Python engine is available on your computer. Knowing both the installed engine and the extension’s intended runtime makes it easier to determine whether a compatibility issue is likely.
Identify the Active Scripting Engine
For a script you control, you can inspect Python’s version information to determine the interpreter that executed it. The sys module provides the sys.version and sys.version_info attributes for this purpose. These values can help distinguish a Python 2.7 environment from a Python 3 environment.
import sysprint(sys.version)print(sys.version_info)
Run this test through the same pyRevit command configuration you want to investigate. Testing in a separate Python application may show the version installed on your computer, not the interpreter running inside Revit. Always verify the actual execution environment before changing scripts or installing dependencies.
Why Python Version Compatibility Matters in pyRevit
Python compatibility affects whether a script can be parsed, whether its libraries can be imported, and whether its operations behave as expected. A command written for Python 3 may contain syntax that Python 2.7 cannot understand. Even when a script uses basic syntax shared by both versions, differences in strings, file handling, and dependencies can still cause problems.
Compatibility also affects the Revit API integration and supporting libraries. A package may require a particular Python implementation or version, while an existing pyRevit extension may rely on functionality that is available only under IronPython. Checking these requirements early helps you choose the appropriate engine and avoid changing working scripts unnecessarily.
Script Syntax and Dependencies
A script’s syntax is one of the first things to check when it fails under a different engine. Features such as f-strings require Python 3, so they cannot be used directly in Python 2.7 scripts. Other language features may require a more recent Python release, meaning that not every Python 3 interpreter supports the same syntax.
Dependencies are equally important. A package may be available for CPython but not compatible with IronPython, or it may require native components that cannot be loaded in the intended environment. Before installing a dependency, verify its supported Python versions, implementation requirements, and compatibility with the runtime used by your pyRevit command.
Revit API and Runtime Compatibility
The Revit API provides access to model elements, parameters, views, sheets, and other project data. A script’s ability to use these features depends not only on Python but also on the Revit version and the way the scripting engine communicates with the API. Changing Python engines alone will not resolve an incompatibility caused by an API change or a missing assembly.
This is why reliable pyRevit development requires checking the full environment. Confirm the Revit version, pyRevit build, scripting engine, and required dependencies before diagnosing an error. A structured compatibility check is more effective than repeatedly changing Python versions without understanding the cause of the problem.
Can You Use Python 3 With pyRevit?
Yes, Python 3 can be used with pyRevit when the selected engine and installed configuration support it. IronPython 3.4.2 and CPython 3.12.3 provide Python 3 environments, but they differ in implementation, package support, and integration with existing pyRevit functionality. You should not assume that every Python 3 feature or library will work identically across both engines.
If you are starting a new automation project, choose the engine based on your requirements and verify that the features you need are supported. If you are updating an older script, review its syntax and dependencies first. Testing a small example in the intended environment is a practical way to identify problems before migrating an entire extension.
Should You Upgrade an Existing Script to Python 3?
Upgrading an older script can provide access to newer language features and compatible libraries, but migration requires careful testing. Start by identifying Python 2-specific syntax, text-handling assumptions, and dependencies that may not work in Python 3. Then make the necessary changes and verify that the script produces the same expected results in Revit.
Not every script needs an upgrade immediately. If an existing tool performs an important task reliably under its current supported engine, changing it without a clear benefit may create unnecessary work. Consider migrating when you need newer language features, improved dependency support, or a more maintainable development environment.
How to Choose the Right Python Version for pyRevit
The right Python engine depends on what you want to build. For maintaining established extensions, compatibility with the existing script environment is often the most important consideration. For new development, modern Python features or access to particular third-party packages may influence your decision, but these benefits must be balanced against the capabilities of pyRevit’s integration.
Before selecting an engine, identify the Revit version you use, the pyRevit build installed, the requirements of your scripts, and the packages they depend on. Check whether your chosen engine is available and supported in that environment. This simple planning process can prevent avoidable errors and help keep your BIM automation tools dependable.
Common Python Errors in pyRevit and How to Avoid Them
Python-related errors in pyRevit can result from unsupported syntax, missing dependencies, incompatible engines, or differences between Revit versions. An error message may point to the line where execution stopped without explaining the underlying compatibility problem. Reviewing the message alongside the script’s requirements is often the best starting point.
Avoid fixing errors by switching Python versions at random. First, determine which interpreter executed the script and whether the failing feature is supported by that interpreter. Then check package availability, required assemblies, and Revit API compatibility. Test each change on a small example before using the updated script in a production project.
Fixing Syntax and Import Errors
Syntax errors often occur when a script uses language features that its interpreter does not support. For example, f-strings in a Python 3 script will fail under Python 2.7. Import errors, meanwhile, may indicate that a package is missing, incompatible with the interpreter, or unavailable through the current runtime configuration.
Read the full error message and identify the first meaningful failure rather than focusing only on the final line. Confirm the Python engine, check the syntax and package requirements, and make one change at a time. This method makes it easier to identify the real cause and reduces the risk of introducing new problems.
Is Python Necessary to Use pyRevit?
No, you do not need Python knowledge to use existing pyRevit commands. Users can benefit from available automation tools through Revit’s interface without writing scripts themselves. Programming becomes necessary when you want to create custom commands, modify script behavior, or automate a task that existing tools do not support.
If you plan to develop your own tools, learning Python fundamentals and understanding the Revit API will help you work more effectively. You can begin with basic scripts and gradually explore engine differences, dependencies, and custom automation. This approach lets you use pyRevit for everyday productivity while developing the skills needed for more advanced BIM workflows.
Frequently Asked Questions About Python and pyRevit
Which Python version does pyRevit use by default?
The traditional default engine is IronPython 2.7.12. Other supported configurations can provide IronPython 3.4.2 or CPython 3.12.3.
Does pyRevit support Python 3?
Yes. Python 3 support is available through compatible IronPython and CPython engines, depending on the installed configuration.
Is IronPython the same as Python?
No. IronPython is a Python implementation designed for the .NET ecosystem, while CPython is the standard Python implementation.
Can Python 2 scripts run in Python 3?
Not always. Differences in syntax, libraries, and behavior may require code changes before a script works correctly.
Can I use regular Python libraries in pyRevit?
Some libraries may work, but compatibility depends on the Python engine, package requirements, and Revit integration.
How can I check my pyRevit Python version?
Inspect the active engine or run a test script using sys.version and sys.version_info in the intended execution environment.
Conclusion
pyRevit supports multiple Python engines, including IronPython 2.7.12, IronPython 3.4.2, and CPython 3.12.3 in supported configurations. The Python version you use depends on your active engine, installed build, and script requirements. Before developing or updating automation tools, check compatibility with your Revit environment and required libraries. Understanding which Python version pyRevit uses helps you avoid common errors and build more reliable Revit automation workflows.