문제

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