1

I tried to install pythonnet in Blender (v2.83) using Windows Power Shell:

cd "C:\Program Files\Blender Foundation\Blender 2.83\2.83\python\bin"
cd ..
.\bin\python.exe -m ensurepip
.\bin\python.exe -m pip install --upgrade pip
.\bin\python.exe -m pip install pythonnet

pythonnet is now correctly present in the pip list. This procedure worked well for example for opencv-python or python-docx.

But after the installation of pythonnet I cannot import the clr namespace in Blender console:

Traceback (most recent call last):
  File "<blender_console>", line 1, in <module>
ModuleNotFoundError: No module named 'clr'

Do you have any suggestions for this problem? Thank you!

Duarte Farrajota Ramos
  • 59,425
  • 39
  • 130
  • 187
igmar
  • 199
  • 1
  • 9
  • 1
    Does this answer your question? How to install Pip for Blender's bundled Python? specifically this part $ /path/to/blenderspython/pip install module – Markus von Broady Apr 05 '21 at 12:16
  • 1
    Hi, unfortunately no: I successfully installed pip for Blender's bundled Python, and it worker for other packages, like python-opencv or python-docx. I have the error only with pythonnet. – igmar Apr 05 '21 at 13:00
  • 1
    IMO would go down the virtual environment road. Make a venv from blender's python install, or a python install of same version dot subversion, point the environment variable BLENDER_SYSTEM_PYTHON to it and start blender from it. – batFINGER Apr 05 '21 at 14:33

1 Answers1

3

How to install any module in Blender:

  1. Give complete permissions to the users of Blender's Python folder: C:\Program Files\Blender Foundation\Blender 2.92\2.92\python (Change the path accordingly to your version. Allowing complete permissions can be risky: do it under your own responsibility. I dind't search for the minimal permissions required yet.)
  2. Download get-pip.py and put it in ...\python\bin folder
  3. From cmd install pip: C:\Program Files\Blender Foundation\Blender 2.92\2.92\python\bin>python.exe get-pip.py
  4. Now you can install any modules C:\Program Files\Blender Foundation\Blender 2.92\2.92\python\bin>python.exe -m pip install pythonnet
Duarte Farrajota Ramos
  • 59,425
  • 39
  • 130
  • 187
igmar
  • 199
  • 1
  • 9