简体   繁体   English

使用PyCharm 4.0.5的Python发生编译错误

[英]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. 尝试运行Python脚本时,我的PyCharm 4.0.5程序出现以下错误。 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. 有一天,它运行良好,当我今天下午尝试使用它时,在尝试运行我100%没有错误的程序后,我遇到了以下错误。 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. 该代码如下所示,我似乎忘记了提及它,它为我计算机上的每个.py脚本提供了完全相同的错误。

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!")

您必须具有一个名为os.py的python文件,而不是“真正的” os模块,该文件将被导入。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM