I just got started with Blender and my main interest is to use code to generate 3D images. I like what I see, but I do not like the fact that I cannot just use any library I want.
Usually, when using other python distributions ( Conda
for example) I would use the following trick in the terminal to install everything I need.
import pip
def install(package):
pip.main(['install', package])
install('requests')
install('numpy')
This however, gives a huge error in blender.
Traceback (most recent call last):
File "<blender_console>", line 1, in <module>
File "/Applications/blender.app/Contents/MacOS/2.71/python/lib/python3.4/pip/__init__.py", line 13, in <module>
from pip.commands import commands, get_summaries, get_similar_commands
File "/Applications/blender.app/Contents/MacOS/2.71/python/lib/python3.4/pip/commands/__init__.py", line 7, in <module>
from pip.commands.freeze import FreezeCommand
File "/Applications/blender.app/Contents/MacOS/2.71/python/lib/python3.4/pip/commands/freeze.py", line 6, in <module>
from pip.req import InstallRequirement
File "/Applications/blender.app/Contents/MacOS/2.71/python/lib/python3.4/pip/req/__init__.py", line 2, in <module>
from .req_install import InstallRequirement
File "/Applications/blender.app/Contents/MacOS/2.71/python/lib/python3.4/pip/req/req_install.py", line 11, in <module>
import pip.wheel
File "/Applications/blender.app/Contents/MacOS/2.71/python/lib/python3.4/pip/wheel.py", line 22, in <module>
from pip import pep425tags
File "/Applications/blender.app/Contents/MacOS/2.71/python/lib/python3.4/pip/pep425tags.py", line 131, in <module>
supported_tags = get_supported()
File "/Applications/blender.app/Contents/MacOS/2.71/python/lib/python3.4/pip/pep425tags.py", line 82, in get_supported
arch = get_platform()
File "/Applications/blender.app/Contents/MacOS/2.71/python/lib/python3.4/pip/pep425tags.py", line 38, in get_platform
return distutils.util.get_platform().replace('.', '_').replace('-', '_')
File "/Applications/blender.app/Contents/MacOS/2.71/python/lib/python3.4/distutils/util.py", line 103, in get_platform
distutils.sysconfig.get_config_vars(),
File "/Applications/blender.app/Contents/MacOS/2.71/python/lib/python3.4/distutils/sysconfig.py", line 511, in get_config_vars
func()
File "/Applications/blender.app/Contents/MacOS/2.71/python/lib/python3.4/distutils/sysconfig.py", line 443, in _init_posix
raise DistutilsPlatformError(my_msg)
distutils.errors.DistutilsPlatformError: invalid Python installation: unable to open /Applications/blender.app/Contents/MacOS/2.71/python/lib/python3.4/config-3.4m/Makefile (No such file or directory)
Can I use pip with blender using this trick? When looking at the error I get the idea that indeed does exist and that I can access it within blender. It is however also telling me that it doesn't use the right python version.
I am using a mac, but preferably we would have a solution here that works for all systems.
EDIT
I still have not gotten pip to work in Blender but as of Blender 2.70 this is not as necessary anymore because Blender now includes the Numpy library (thanks community!)