Unable to load coreclr from Pythonnet in blender 4.0 #115778
Labels
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser
Interest
Asset Browser Project Overview
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
EEVEE & Viewport
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
EEVEE & Viewport
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No project
No Assignees
3 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: blender/blender#115778
Loading…
Reference in New Issue
No description provided.
Delete Branch "%!s(<nil>)"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
System Information
Operating system: Linux-6.2.0-37-generic-x86_64-with-glibc2.35 64 Bits, X11 UI
Graphics card: NVIDIA GeForce RTX 3080 Ti/PCIe/SSE2 NVIDIA Corporation 4.6.0 NVIDIA 535.129.03
Blender Version
Broken: version: 4.0.1, branch: blender-v4.0-release, commit date: 2023-11-16 16:40, hash:
d0dd92834a08
Worked: 3.0.1
Short description of error
I'm trying to load coreclr via pythonnet in blender 4.0 but keep receiving the follow stack trace in my blender console:
The reason I believe this problem is blender-specific is because I'm able to load coreclr in blender 3.0.1, but it is now broken in 4.0.1. I isolated the issue to be about loading the coreclr via pythonnet into blender 4.0 and captured it in a plugin I've attached. I witnessed the issue when I used a larger plugin that also used pythonnet and loaded coreclr, but I don't believe the full plugin is needed to replicate the error. I have tried a couple different ideas to further narrow the problem and see if anything else might cause the it:
Exact steps for others to reproduce the error
Preferences -> Interface
.load pythonnet
.It seems that the Pythonnet version 3.0.3 is not compatible with the Python version that comes with Blender 3.1+:
To address this, you may want to try using a different version of Pythonnet that is compatible with Blender or consider using a different approach to achieve your desired functionality.
If you need further assistance, please feel free to provide additional details or seek help on the Blender community sites.
Can I ask how you produced those errors? If that's a pip error, pythonnet's current version is 3.0.3, so you should be able to just download it via something like
pip install pythonnet
.I made a mistake in the previous installation. But I tried again and I can't reproduce the problem.
Looking at the error log, this problem should simply be replicable with the following commands:
Note that the
python.exe
used is the one that comes within Blender, and the modules must be installed in that module's library within Blender.But in your error log, the module directory is:
"~/.local/lib/python3.10/site-packages/pythonnet/__init__.py"
.This shows that you are using the module from another location, probably incompatible.
Could you ensure that you are installing and using the
pythonnet
module strictly within the Blender's Python environment?Please rerun the installation and test with the noted commands, ensuring that you are referencing the correct
python.exe
that is bundled with Blender.Did you try reproducing the problem in blender? I'm able to perform the commands you suggested using blender's python binary directly and am able to replicate your result that there aren't any issues.
However, when I try to load coreclr inside of blender say in the python console, it fails with the original error. I verified that the pythonnet install I'm using is local to the python blender binary and is using the right python executable.
I also purged any other instances of pythonnet from my computer and reinstalled pythonnet to the local folder after ensuring it failed to import pythonnet.
Here's the error posted again for clarity in case something I didn't notice changed:
Yes, and the addon worked normally in Blender.
I think the problem is not related to Blender.
Check environment variables such as PYTHONPATH, they can cause Python to use some modules in the system which can result in incompatibility.
I noticed that you use Linux. Perhaps this could influence the result. I'll let someone else on the triage team take a look.
I think the problem is Blender Linux-related because I know this works fine on Blender on Windows. I should have probably mentioned that upfront, but I thought the System Info in the initial post would be enough.
I checked PYTHONPATH, but it's empty.
So I just tried importing pythonnet into blender via my laptop with the same Ubuntu distro and version as my desktop (Ubuntu 22.04 LTS), and I again received the same error. Pythonnet is again installed locally within the python binary supplied by blender. The only difference between the two setups is that my laptop has blender 4.0.2 and my desktop has blender 4.0.1. Any help would be appreciated on how to move forward. I'm completely blocked by this issue.
To reiterate the steps to reproduce the issue are as follows:
<PATH_TO_BLENDER>/4.0/python/bin/python3.10 -m pip install pythonnet
this error is the important one
validating manually:
I don't have a working linux build currently, but i'd probably try linking the python libs with the
--whole-archive
flagI downloaded the blender source code and followed the build instructions at https://wiki.blender.org/wiki/Building_Blender/Linux/Ubuntu and am wondering where you suggest I add the
--whole-archive
flag? I can't find explicitly where the python library is linked duringmake
, but I did find whatmake
uses to build the python library.I just hacked into my
build.ninja
file, but can confirm linking the python libs that way fixes the issue, i'd leave the actual fix up to the linux platform maintainer.we currently have
PYTHON_LINKFLAGS
where we could easily add this flag, however this is only half the battle, after the python libs are linked, order has to be restored and--no-whole-archive
has to be passed or all libs that follow will be linked that way.Thank you for following up. I figured out a way to rebuild using
--whole-archive
onlibpython3,11.a
when buildingbf_python_ext
and that successfully fixes the issue on my end.In the meantime, for anyone who runs into this issue as well, I had to modify
macros.cmake
and add this code snippet toblender_link_libraries:380
since like you said we need to wrap the library within
--whole-archive
and--no-whole-archive
. After adding this code, I rebuilt from scratch and reinstalled pythonnet to the provided python binary and now it works. This fix is a gross hack that's on a critical build path though, so I agree that we should wait for a proper fix as indicated by Ray.Tagging @ideasman42 (who might have more insight into this issue).