apparently spyder does not recognize "import math" correctly

已查看 1,874 次
跳至第一个未读帖子

murdock...@gmail.com

未读,
2016年8月20日 11:40:462016/8/20
收件人 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

未读,
2016年8月21日 02:07:392016/8/21
收件人 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'>
回复全部
回复作者
转发
0 个新帖子