Question

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!

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top