{"id":23252,"library":"ansys-pythonnet","title":"ansys-pythonnet","description":"Ansys fork of pythonnet providing .NET and Mono integration for Python. Version 3.1.0rc6, targeting Python 3.7-3.13. Active development with release candidate status.","status":"active","version":"3.1.0rc6","language":"python","source_language":"en","source_url":"https://github.com/pyansys/ansys-pythonnet","tags":["pythonnet","dotnet",".net","interop","clr","ansys"],"install":[{"cmd":"pip install ansys-pythonnet","lang":"bash","label":"Latest release candidate"},{"cmd":"pip install ansys-pythonnet==3.1.0rc6","lang":"bash","label":"Exact version"}],"dependencies":[{"reason":"Core .NET integration module","package":"clr","optional":false}],"imports":[{"note":"pythonnet is the package name; the top-level module is clr.","wrong":"import pythonnet","symbol":"clr","correct":"import clr"},{"note":"Use from System import ... to import specific .NET types.","wrong":"import System","symbol":"System","correct":"from System import Array, String"}],"quickstart":{"code":"import clr\n# Add reference to a .NET assembly\nclr.AddReference('System.Windows.Forms')\nfrom System.Windows.Forms import MessageBox\nMessageBox.Show('Hello from .NET!')","lang":"python","description":"Basic usage: import clr, add a .NET assembly reference, and import .NET namespaces."},"warnings":[{"fix":"Replace 'pythonnet' with 'ansys-pythonnet' in requirements.txt and environment.","message":"The PythonNET (pythonnet) fork renamed to ansys-pythonnet. Import statements remain 'import clr' but package name changed. Existing code using 'pythonnet' package will not work; reinstall with 'pip install ansys-pythonnet'.","severity":"breaking","affected_versions":"all versions of this fork"},{"fix":"Use assembly name without extension: clr.AddReference('System.Windows.Forms') instead of path.","message":"clr.AddReference works, but the newer recommended approach uses 'import clr' and then 'clr.AddReference' with assembly names. Avoid loading assemblies via absolute paths if possible.","severity":"deprecated","affected_versions":">=3.1.0rc1"},{"fix":"Use Python 3.12 or earlier. Check official repo for updates.","message":"Python 3.13 is not fully supported yet; current version supports <3.14,>=3.7 but only tested up to 3.12. Use Python 3.12 or earlier for stable behavior.","severity":"gotcha","affected_versions":"3.1.0rc6"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Install ansys-pythonnet: pip install ansys-pythonnet","cause":"Missing ansys-pythonnet package or mistakenly installed old pythonnet package which does not expose clr.","error":"ImportError: No module named clr"},{"fix":"Ensure ansys-pythonnet is installed and imported as 'import clr'. Check for clr files shadowing from other packages.","cause":"Using 'import clr' but not loading the module correctly; possibly a namespace conflict or incomplete install.","error":"AttributeError: module 'clr' has no attribute 'AddReference'"},{"fix":"Ensure both Python and .NET runtime use the same bitness. Use 64-bit Python with 64-bit .NET assemblies.","cause":"Mismatch between Python architecture (32-bit vs 64-bit) and .NET assembly target.","error":"System.BadImageFormatException: Could not load file or assembly ..."}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}