14

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.

ideasman42
  • 47,387
  • 10
  • 141
  • 223
john mangual
  • 333
  • 2
  • 4
  • 9

4 Answers4

11

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.

Cal McLean
  • 226
  • 1
  • 4
  • 3
    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. – m3nda Sep 06 '16 at 13:41
  • I realize this is old, but to for anyone else with the same question as @m3nda: You can run blender in a GUI-less mode and excecute your python script via: blender --background --python my_script.py -- my_argument1 my_argument or similar. – Germanunkol Mar 28 '22 at 07:31
8

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.

Polosson
  • 6,544
  • 8
  • 33
  • 61
4

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.

Adhi
  • 14,310
  • 1
  • 55
  • 62
1

You can use fake-bpy-module instead.

From the description of the repo:

fake-bpy-module is the collections of the fake Blender Python API modules for the code completion in commonly used IDEs.

haisu
  • 111
  • 1