Content · Programming · Python

PyCharm Locate Your Project on Disk

Knowing where a project is stored on disk helps you run scripts outside PyCharm and find files created by a program. Learn the essential ideas and try a practical example.

2 views Published Oct 17, 2026 Updated Oct 18, 2026 Admin

Knowing where a project is stored on disk helps you run scripts outside PyCharm and find files created by a program.

Understanding the Concept


The Project panel presents your project hierarchy. You can right-click a folder and choose to reveal it in the operating-system file manager, or inspect the path from PyCharm’s project settings. Do not confuse the source folder with the project interpreter directory. When a script creates an output file using a relative path, the file goes to the current working directory specified by the run configuration.

When and Why You Would Use This


Use pathlib to inspect an absolute working directory and an absolute source file path. The script reveals where it is running and where it is stored; these locations can be different.

Practical Example


from pathlib import Path
print("Working directory:", Path.cwd())
print("This file:", Path(__file__).resolve())

Understanding the Example


Run this example from a saved .py file. The special __file__ variable is defined for normal Python script files, but it may be missing in some interactive or notebook environments. Compare the two paths.

Example Output


Working directory: /tmp/knowstuff_python_qa_ra95x87f
This file: /tmp/knowstuff_python_qa_ra95x87f/example.py

Try It Yourself


Reveal your project folder in the file manager. Find main.py and compare its location with the script output.

Common Beginner Mistakes


  • Assuming the Run window folder is the same as the source folder.
  • Losing files by creating projects under temporary download directories.
  • Using __file__ in the interactive shell where it may not exist.

Key Takeaways


  • A project folder stores your source and IDE project files.
  • Working directory and source-file location are different concepts.
  • Use Path.cwd() and file-manager reveal actions to locate files reliably.
Share this resourceSend this page to someone who may find it useful.