Answer a question

I've seen this question being asked before (at least twice), but I haven't found a solution so far, so I'll ask the question again with some more details.

The Problem

When I run my python main file, PyCharm keeps telling me Cannot start process, the working directory /home/myname/PyCharmProjects/MyProjectName/mypackage does not exist.

When did this error occur?

After I created a package mypackage for test purposes, moved files to it (inluding my main file), and moved the files back to the root folder afterwards.

The package mypackage was empty after that, but PyCharm still thought that the main file (Main.py) is located in that package. I could still run the program until I deleted the empty package, but path errors occurred. After deleting the package, I was unable to start it.

Additional Info

  • I can still run the other files that used to be in mypackage and are now in my root directory again
  • I can still create and run new files in my root directory

Answers

After testing for a bit, I've found a solution (but not an answer to why this error occurs in PyCharm):

Delete the file and create it again. (Or rename or move it and create a new file with its old name, both should work.)

Logo

Python社区为您提供最前沿的新闻资讯和知识内容

更多推荐