1
$\begingroup$

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!

$\endgroup$
3
  • 1
    $\begingroup$ Does this answer your question? How to install Pip for Blender's bundled Python? specifically this part $ /path/to/blenderspython/pip install module $\endgroup$ Commented Apr 5, 2021 at 12:16
  • 1
    $\begingroup$ 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. $\endgroup$
    – igmar
    Commented Apr 5, 2021 at 13:00
  • 1
    $\begingroup$ 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. $\endgroup$
    – batFINGER
    Commented Apr 5, 2021 at 14:33

1 Answer 1

3
$\begingroup$

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
$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .