ImportError: No module named 'bpy'

Minn Trih picture Minn Trih · Oct 29, 2014 · Viewed 12.5k times · Source

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     
sys.path.append("C:\Python34\Lib\site-packages")    
import serial    
import GameLogic    
contr = GameLogic.getCurrentController()    
own = contr.owner    
dane=open('dane.txt', 'rb')    
x=dane.read()    
dane.close()    
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'  

Answer

hamed aghapanah picture hamed aghapanah · Mar 9, 2021

I have this problem in collab but on my PC it was worked well:

enter image description here

type this in your anaconda prompt:

pip install bpy

Source: https://pypi.org/project/bpy/)