6
$\begingroup$

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!)

$\endgroup$
1

2 Answers 2

6
$\begingroup$

What you can do is just delete the python folder from the Blender directory (or move it to have a backup) and Blender will look for python preinstalled on the system. Note that the version must match (current Blender python version is 3.5.0, it works with 3.5.1 though) and environment variables need to be set (at least under Windows).

Info from here.

$\endgroup$
1
  • $\begingroup$ This doesn't work for me on Ubuntu 14.04 with Blender 2.76b. I suspect a Python version mismatch. But you can use pip now, if you replace distutils. $\endgroup$ Commented Feb 11, 2016 at 6:51
2
$\begingroup$

You might try to extend sys.path to use modules installed with another python distribution on your system.

The default installation of python 3.4 uses these paths:

C:\Windows\system32\python34.zip C:\Python34\DLLs C:\Python34\lib C:\Python34 C:\Python34\lib\site-packages 
$\endgroup$

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.