Blender has built-in Python and can execute various scripts. However, the installed modules are limited to numpy
etc., and it takes a little work to add your favorite module, so I will explain it.
With the default settings, Blender should be stored in the following location:
C:\Program Files\Blender Foundation\Blender\2.80
Python below this is built-in. (It's different from Python that I installed individually)
C:\Program Files\Blender Foundation\Blender\2.80\Python\python.exe
You can also find pip.exe
(module to install) in the following location.
C:\Program Files\Blender Foundation\Blender\2.80\python\Scripts
**! The version may be 2.81 or 2.80, so please adjust it yourself **
This pip
does not have a path (it does not refer to this pip
), so at the command prompt, for example,
pip install pandas
I can't pass it. (If another Python is installed, it will be installed there)
If you don't have a pass, you can just refer to the location directly.
C:\Program Files\Blender Foundation\Blender\2.80\python\Scripts\pip install pandas
If you do, it will not be OK ..., and in fact, it will take another effort, and this will not work due to the administrator privileges of Windows.
C:\Program Files\Blender Foundation\Blender\2.80\python\Scripts\pip install pandas --user
This will work.
Please note that the working directory is
>>> import os
>>> os.getcwd()
'C:\\Program Files\\Blender Foundation\\Blender'
Therefore, if you perform an operation such as creating a file and referencing it, an error will occur if you do not have administrator privileges. Start Blender with administrator privileges, or create and browse files under the user directory.
For Mac, Blender should be stored in the following location:
/Applications/Blender.app/Contents/Resources/2.81
**! The version may be 2.81 or 2.80, so please adjust it yourself **
However, for some reason pip is not installed. You need to install pip.
Open the terminal,
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
/Applications/blender.app/Contents/Resources/2.81/python/bin/python3.7m get-pip.py
**! The version of python is 3.7 or 3.5, so please adjust it individually **
Will generate pip
.
The rest is the same,
/Applications/blender.app/Contents/Resources/2.81/python/bin/pip install pandas
Installation is complete.
By the way, when I try to import pyplot
on Windows, I get the following error.
It is said that there is no _tkinter
. Looking at the contents of the tkinter / __ init__.py
that was imported immediately before,
"If this fails, your Python may not be tuned for Tk."
This may not be the case with normal (?) Python installed separately, so it may be a problem specific to built-in Python.
For the time being, there is a trick to copy the separately installed python under C: \ Program Files \ Blender Foundation \ Blender \ 2.80 \
** together with the folder ** (the original python folder was renamed). And evacuate). With this, you can bring the environment as it is. However, I couldn't draw the graph with pyplot.show ()
. This method may be useful if the built-in Python just can't pip
the module.
On MacOS, I don't get this error, but I still couldn't draw with pyplot.show ().
Drawing a graph in Blender seems difficult (although it doesn't seem necessary much).
Recommended Posts