Wasp15 Wasp15 - 2 months ago 25
Python Question

Having a compiling error with Python using PyCharm 4.0.5

The reason for me asking the question here is that I did not find a solution elsewhere. I'm having the following error with my PyCharm 4.0.5 program while trying to run a Python script. It was working fine the one day and when I tried using it this afternoon I got the following error after tying to run a program which I am 100% has no errors in it.
In the message box I got the following error:

Failed to import the site module
Traceback (most recent call last):
File "C:\Python34\lib\site.py", line 562, in <module>
main()
File "C:\Python34\lib\site.py", line 544, in main
known_paths = removeduppaths()
File "C:\Python34\lib\site.py", line 125, in removeduppaths
dir, dircase = makepath(dir)
File "C:\Python34\lib\site.py", line 90, in makepath
dir = os.path.join(*paths)
AttributeError: 'module' object has no attribute 'path'

Process finished with exit code 1


I have never seen an error of this kind and don't know where to start tackling this problem.

Any feedback will be greatly appreciated!

The code looks like the following, and I seem to have forgotten to mention that it gives me the exact same error for every single .py script on my computer.

import turtle
wn = turtle.Screen()
alex = turtle.Turtle()


def hexagon(var):
for i in range(6):
alex.right(60)
alex.forward(var)


def square(var):
for i in range(4):
alex.forward(var)
alex.left(90)


def triangle(var):
for i in range(3):
alex.forward(var)
alex.left(120)


def reset():
alex.clear()
alex.reset()
x = True
while x:
alex.hideturtle()
choice = input("""
Enter the shape of choice:
a. Triangle
b. Square
c. Hexagon
""")
if choice.lower() == "a":
length = input("Enter the desired length of the sides: ")
triangle(int(length))
restart = input("Do you wish to try again? Y/N ")
if restart.lower() == "n":
x = False
else:
reset()
if choice.lower() == "b":
length = input("Enter the desired length of the sides: ")
square(int(length))
restart = input("Do you wish to try again? Y/N ")
if restart.lower() == "n":
x = False
else:
reset()
if choice.lower() == "c":
length = input("Enter the desired length of the sides: ")
hexagon(int(length))
restart = input("Do you wish to try again? Y/N ")
if restart.lower() == "n":
x = False
else:
reset()
print("Thank you for using your local turtle services!")

Answer

You must have a python file named os.py which is being imported instead of the "real" os module.