apparently spyder does not recognize "import math" correctly

1,896 views
Skip to first unread message

murdock...@gmail.com

unread,
Aug 20, 2016, 11:40:46 AM8/20/16
to spyder
I am using Spider 2.3.9  with Python 3.5  and having problem with using the math library.  I have found at least three instances of the math.py library in the installation  however my program does not seem to recognize the math library.  I tested this by executing x=cos(25) on the command line and it says "Nameerror COS not defined.  I get the same type of error when I run my program.

Has anyone had a similar problem and is there a cure for this problem.

THanks  in advance

M

Björn Johansson

unread,
Aug 21, 2016, 2:07:39 AM8/21/16
to spyder
Hi, tis works for me (see below). A common cause of this kind of problem is if you have 
a file called math.py somewhere on your path that will be imported instead of the standart library module. type "math" at the prompt to see which module was imported (see last line below). 

DEPRECATED: IPython.core.usage.default_gui_banner is deprecated and will be removed
Python 3.5.2 |Anaconda custom (64-bit)| (default, Jul  2 2016, 17:53:06) 
Type "copyright", "credits" or "license" for more information.

IPython 5.1.0 -- An enhanced Interactive Python.
?         -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help      -> Python's own help system.
object?   -> Details about 'object', use 'object??' for extra details.

import math

math.cos(25)
Out[2]: 0.9912028118634736

math
Out[3]: <module 'math' from '/home/bjorn/anaconda/envs/bjorn3/lib/python3.5/lib-dynload/math.so'>
Reply all
Reply to author
Forward
0 new messages