Why Python 3.4 standard libraries don’t work in Sublime Text?
Running (example in Mark Lutz book) in myth.py in SublimeText:

import math
math.pi
math.sqrt(9)

and get

Traceback (most recent call last):
  File "/Users/*myusername*/Desktop/python/math.py", line 1, in <module>
    import math
  File "/Users/*myusername*/Desktop/python/math.py", line 2, in <module>
    math.pi
AttributeError: 'module' object has no attribute ‘pi'

Do it in terminal or EDLE and all works fine!

有帮助吗?

解决方案

Try renaming your file to something besides math.py. You are trying to import the math module, and Python is choking because it's trying to import itself, and there's no pi() function defined. If you change your filename to something like py34_math_test.py you should be all set.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top