質問

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