Working directory error

I also got this error, and it got resolved by setting the default working directory. Follow the below path, and set the Working Directory to the folder where your code resides.

File > Settings > Build, Execution, Deployment > Console > Python Console > Working Directory ...


I finally solved the problem.

I think it all started because the first project that I opened with pycharm was in my "download" folder, so the working directory was automatically set to a temporal folder by default and allthough I moved the project to another folder and I manually changed the working directory from the terminal, it was not working.

The solution was creating a new project and giving a correct path to the new project. It seems very easy but it was not that obvious.


Another solution is to close the project, run rm -rf .idea and re-open it. Apparently Pycharm gets confused by some direct folder manipulation and doesn't reflect it properly in his .idea/*.xml files


  • In the upper right corner click on small next to your main to run (look to the left from green right-pointing triangle)
  • Select Edit configurations.
  • In ▼ Python select the proper configuration name.
  • Look at the Configuration panel.
  • Fix items Script and Working directory.

pycharm