9
$\begingroup$

After sudo apt-get install blender on Ubuntu 12.10, I have Blender version 2.63

However, I can not import the relevant scripting Library

Python 3.2.3 (default, Sep 25 2013, 19:36:10) 
[GCC 4.7.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import bpy
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named bpy
>>> import Blender
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named Blender

Later on, I would like to use numPy and Blender to create some figures for 3D printing, as a friend has suggested.

$\endgroup$
8
$\begingroup$

bpy is only available when a script is being run from the Python interpreter in Blender. You can't access it from an external interpreter. The bpy module itself is located in the Python environment supplied with Blender (if you download the zip-file, rather than the installer).

To use the bpy module, open the script in Blender's Script Editor.

$\endgroup$
  • 2
    $\begingroup$ Well, does exist a coomand line to launche blender script editor then "paste" or "run" any other script then export?. I mean without use GUI/X and of course, without the "experimental" blender as python module. Maybe the answer is " the experimental " but, i must ask. thx. $\endgroup$ – erm3nda Sep 6 '16 at 13:41
7
$\begingroup$

As far as I know, this can't be done straight forwardly.

But, there is an experimental feature you can try. Basically you build a Blender with some special CMAKE settings. Here is the complete "HowTo" (from @Ideasman): Blender as a Python Module.

Also notice that Blender (currently) works with python 3.3.

$\endgroup$
  • $\begingroup$ That is interesting. I should try it out sometime. $\endgroup$ – user877329 Jul 7 '16 at 7:19
  • $\begingroup$ really interesting ... exporting 3d models as scripts, so you can easily modify some parts before rendering/exporting. $\endgroup$ – erm3nda Sep 6 '16 at 13:39
  • $\begingroup$ the link is broken, is there any chance you can update? $\endgroup$ – Nick Brady Sep 18 at 12:16
  • $\begingroup$ Sorry, the page is gone (certainly with the rise of Blender 2.8). But you may find something interresting in there : pypi.org/project/bpy (I haven't tried it BTW). $\endgroup$ – Polosson Sep 19 at 13:21
3
$\begingroup$

The bpy module is only accessible from the Python interpreter built-in to Blender. It is tightly integrated to Blender's runtime process, and is not primarily meant to be accessed like a library from a standalone Python process.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.