Note installing modules such as pytorch and opencv with pip in Blender python (2.82a or later)

background

I want to visualize 3D face data using OpenCV or dlib in Blender, or combine it with machine learning in cooperation with pytorch.

environment

pip installation

In the initial state, pip is not included, so ensure pip https://docs.python.org/ja/3/library/ensurepip.html

Install with.

$ /path/to/blender/2.82/python/bin/python3.7m -m ensurepip

After this, you can use it with -m pip.

$ /path/to/blender/2.82/python/bin/python3.7m -m pip

Modules that require C / C ++ compilation

Some modules, such as dlib, need to be compiled from source code during pip.

Python 3.7 development environment (header file) is required. Blender does not include Python.h etc.

Use system python dev

For Ubuntu 18.04, put python3.7-dev with apt,

$ env CXXFLAGS="-I/usr/include/python3.7m" /path/to/blender/2.82/python/bin/python3.7m -m pip install dlib

If you add a header path with CXXFLAGS, for the time being, pyconfig.h is different, so I'm a little worried.

Get header files from Python source code (recommended)

I think it is safe to drop the python source code and install the header related items in / path / to / blender / 2.82 / python / include / python3.7m on the blender side.

You should now be able to install modules that require C / C ++ compilation!

You should be able to import it in the Blender Python console!

blender-python.png

TODO

Recommended Posts

Note installing modules such as pytorch and opencv with pip in Blender python (2.82a or later)
Draw a watercolor illusion with edge detection in Python3 and openCV3
Organize python modules and packages in a mess
How to generate a QR code and barcode in Python and read it normally or in real time with OpenCV
Start numerical calculation in Python (with Homebrew and pip)
It is blocked by Proxy, a connection error occurs in Python or pip, and it is retried.
Convert RGB and HSV in a differentiable form with PyTorch
Grayscale image is displayed as a color image in OpenCV / Python
Python 3.4 or later standard pip
I made a simple circuit with Python (AND, OR, NOR, etc.)
Create a striped illusion with gamma correction for Python3 and openCV3
How to make a surveillance camera (Security Camera) with Opencv and Python
How to deal with errors when installing Python and pip with choco
Install pip in Serverless Framework and AWS Lambda with Python environment
Shining life with Python and OpenCV
Install Python 2.7.9 and Python 3.4.x with pip.
Neural network with OpenCV 3 and Python 3
Use blender as a python module
[Python] return A [or / and] B
Use OpenCV with Python 3 in Window
Easy modeling with Blender and Python
Get started with Python in Blender
How to input a character string in Python and output it as it is or in the opposite direction.
Put OpenCV in OS X with Homebrew and input / output video with python
Modules of frequently used functions in Python (such as reading external files)
Addressed "Python .h: No such file or directory" when installing uWSGI with Python 3.8
Spiral book in Python! Python with a spiral book! (Chapter 14 ~)
Modules and packages in Python are "namespaces"
Install Python as a Framework with pyenv
Blender 2.82 or later + python development environment notes
Python installation and package management with pip
Capturing images with Pupil, python and OpenCV
A memo with Python2.7 and Python3 on CentOS
Connect a lot of Python or and and
Put Docker in Windows Home and run a simple web server with Python
[Python] Get product information such as ASIN and JAN with Amazon PA-API ver5.0
A complete guidebook to using pyenv, pip and python in an offline environment