简体   繁体   English

运行代码时在Pycharm中找不到目录

[英]Directory not found in Pycharm when running code

I get an error by running my code in pycharm. 我在pycharm中运行代码时遇到错误。 I get this message : 我收到此消息:

C:\\Python27\\python.exe: can't open file 'C:/Users/Melinda/PycharmProjects/untitled/classParticipant.py': [Errno 2] No such file or directory C:\\ Python27 \\ python.exe:无法打开文件'C:/Users/Melinda/PycharmProjects/untitled/classParticipant.py':[Errno 2]没有此类文件或目录

Process finished with exit code 2 I understand that I don't have the Folder named untitled, because I have renamed it afterwards as Lab4. 以退出代码2结束的​​过程我知道我没有名为untitled的文件夹,因为此后我将其重命名为Lab4。 enter image description here 在此处输入图片说明

You've borked your project by renaming the directory yourself rather than renaming the project from within the IDE. 您通过自己重命名目录而不是从IDE中重命名项目来使项目感到厌倦。

You need to close and delete the project (do not delete the files when it asks). 您需要关闭并删除项目(在询问时不要删除文件)。 If you feel unsure about this copy your files to a backup location first. 如果您对此不确定,请先将文件复制到备份位置。 Then reopen the project using "Open" from the file menu. 然后使用文件菜单中的“打开”重新打开项目。

I wouldn't go that far to delete the project, have a go at going to 我不会去删除项目,而是去

Settings -> Project -> Project Structure

and then removing and re-adding the project root. 然后删除并重新添加项目根目录。

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

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