# Python Math Functions Fail In Blender

My problem is this: I try and run the script in Blender's text editor and the script fails to math functions, cos() does not work.

When I run the same code in Blender's Python console my pasting it directly, there is no problem What is the reason / how to get it work from the Text Editor?

• You need to either use the math namespace because you've imported it eg math.cos(angle) or to use directly, from math import cos. For convenience sake the math and mathutils methods have been imported for you in the console. from math import * (See banner message). – batFINGER Nov 12 '17 at 16:52
• Always check the system console for errors. NameError: name 'cos' is not defined – batFINGER Nov 12 '17 at 16:59

Answered by @batFINGER in a comment: You need to either use the math namespace because you've imported it eg math.cos(angle) or to use directly, from math import cos. For convenience sake the math and mathutils methods have been imported for you in the console. from math import * (See banner message).