# 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). Nov 12 '17 at 16:52
• Always check the system console for errors. NameError: name 'cos' is not defined Nov 12 '17 at 16:59

## 1 Answer

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).

• The information in the answers turned out to be useful. I could deduce the syntax at least for the math functions I needed. Now the script works technically. Only thing left is to make it work logically :) Nov 13 '17 at 21:56
• Then at least upvote it and accept it as answer. Nov 19 '17 at 11:02
• Sorry for my ignorance. Answer accepted with pleasure. Nov 20 '17 at 23:32