Search code examples
pythonpycharm

"Cannot start process, the working directory ... does not exist" error in PyCharm


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

This error occurred after creating a package (mypackage) for test purposes, moving files to it (including Main.py), and moving the files back to the root folder afterwards.

The package mypackage was empty after that, but PyCharm still thought that 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.

  • 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.

Solution

  • 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.)