I am getting error:

ImportError: No module named 'bpy' in Blender console.

I am importing bpy module inside Blender console but still getting the error. After long googling I found that no one is getting the same error inside Blender.

Using Blender 2.7 and python 3.4.

My code:

import sys   
import bpy     
import serial    
import GameLogic    
contr = GameLogic.getCurrentController()    
own = contr.owner    
dane=open('dane.txt', 'rb')    
y = int(x)    
print ("y=", y)    

bpy.ops.transform.rotate(value=(y), axis=(0.0, 0.0, 0.0), constraint_axis=(False, False, False), constraint_orientation='', mirror=False, proportional='DISABLED', proportional_edit_falloff='SMOOTH', proportional_size=1.0, snap=False, snap_target='CLOSEST', snap_point=(0.0, 0.0, 0.0), snap_align=False, snap_normal=(0.0, 0.0, 0.0), release_confirm=False)

Output at Blender console:

ImportError: No module named 'bpy'  
Python script error - object 'Cube', controller 'Python':  
Traceback (most recent call last):  
File "qqq.py", line 2, in <module>  
ImportError: No module named 'bpy'
  • 1
    $\begingroup$ There's at least one additional problem: the backslashes in the filepath are not escaped, you can fix this by adding an r in front of the starting quotation mark - sys.path.append(r"...") $\endgroup$
    – CodeManX
    Oct 30 '14 at 11:32
  • $\begingroup$ Thanks dear friend for your reply. This problem persists only in Standalone Player, not in embedded player. But I need the standalone player. :( Have any solution dear ? $\endgroup$
    – Minn Trih
    Oct 30 '14 at 11:51

The blenderplayer doesn't include bpy

  • $\begingroup$ Do you mean to say that there is no way to include bpy in Standalone Player? And when we export the game runtime as an .exe, in which player the game is played(Embedded or Standalone)? $\endgroup$
    – Minn Trih
    Oct 31 '14 at 4:19
  • $\begingroup$ correct. unless you modify the player code in C/C++ to include it (not trivial) $\endgroup$
    – ideasman42
    Oct 31 '14 at 7:37
  • $\begingroup$ What is the procedure to include that bpy in C/C++? Because I need to publish the game for end-users. Please share any method to include bpy in exported runtime version. Any method will help. $\endgroup$
    – Minn Trih
    Oct 31 '14 at 11:51
  • $\begingroup$ By not trivial I mean you can't do it unless you spend some hours in the code - this needs a developer to look into it, and infact its intentionally setup this way. since bpy is for blender -the application. You would be better off to just run Blender application fullscreen I expect. $\endgroup$
    – ideasman42
    Oct 31 '14 at 11:53

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.