PyCharm Project Creation and Management
In PyCharm, a Project is the most basic unit of work; it contains source code, configuration, dependencies, and environment settings.
This section details how to create and manage Python projects in PyCharm.
1. Create a new project
1.1 Create from the welcome screen
PyCharm actually provides many shortcuts when it starts:

The screen on first launch is as follows:

Click "New Project" (New Project).
Alternatively, from the menu bar File, click "New Project (New Project)".

Configure project settings:
**Location:** Choose and set the project storage path and name.
**Interpreter:** Project venv (recommended).

venv is a Python module for creating and managing virtual environments. A virtual environment is an isolated space that lets you install and manage Python packages without affecting other Python environments on the system.
venv is part of the standard library in Python 3.3 and above, so no extra tools are needed to use it.
- Project venv: the virtual environment is stored by default in the venv folder under the project directory.
- Base Conda (if Anaconda/Miniconda is installed)
- Custom environment
**Project template:**
- Select a project type, such as "Pure Python" or "Flask" (for web development).
- A main.py file is created by default, containing a simple Python code template (e.g., print("Hello, World!")).
1.2 Create a project from existing code
If you already have Python code, import it in the following ways:
Welcome screen -> "Open" (Open), select the project directory or File -> Open (File -> Open), select the project folder.
PyCharm automatically detects the Python environment; if none is found, you can configure the interpreter manually.

2. Project management
2.1 Project structure
The default PyCharm project structure is as follows:
my_project/
├── .idea/ # PyCharm 配置文件(如运行配置、版本控制设置)
├── venv/ # 虚拟环境(如果使用 Virtualenv)
├── main.py # 示例代码(如果勾选了 "创建 main.py")
└── 其他文件/目录 # 用户创建的代码文件
Note: the .idea/ and venv/ folders usually do not need manual editing; PyCharm manages them automatically.
2.2 Configure the Python interpreter
If the project needs a different Python environment (e.g., switching from Python 3.8 to 3.10):
File -> Settings -> Project -> Python Interpreter (Windows/Linux: Ctrl+Alt+S, macOS: Cmd+,).
Click the gear icon -> Add Interpreter, and choose:
-
Virtualenv(recommended)
-
System Python(use the global Python directly)
-
Conda environment(if using Anaconda)
Select the Python version and click "OK".
2.3 Run/Debug configurations
PyCharm lets you set different run modes for different scripts:
-
Top toolbar -> Run Configurations → "Edit Configurations".
-
Click +, select Python, configure:
-
Script path: select the
.pyfiles. -
Python interpreter: make sure the correct environment is selected.
-
Parameters: you can enter command-line arguments (e.g.,
--port 8000).
Script path: select the .py files.
Python interpreter: make sure the correct environment is selected.
-Parameters: you can enter command-line arguments (e.g., --port 8000).
-
Click "Apply", then you can click Run or Debug.
3. Common project operations
3.1 Open multiple projects
PyCharm defaults to single-project mode (only one project open at a time), but you can manage multiple projects as follows:
-
File -> New -> Project (File -> New -> Project), to create a new project (PyCharm will ask whether to open it in a new window).
-
or File -> Open (File -> Open), select another project directory.
3.2 Close / reopen a project
-
Close the current project:
文件 → 关闭项目(File → Close Project), returning to the welcome screen. -
Reopen a recent project: the welcome screen shows "Recent Projects" (Recent Projects), click it to reopen.
3.3 Project dependency management (requirements.txt / pyproject.toml)
PyCharm can automatically detect requirements.txt or pyproject.toml and install dependencies:
Right-click requirements.txt -> "Sync Python Requirements".
Or run in the Terminal:
pip install -r requirements.txt
To export the current environment's dependencies:
pip freeze > requirements.txt
4. Frequently asked questions
Q1: PyCharm cannot recognize Python files?
-
Check the file extension: make sure it is
.pyfiles. -
Check the interpreter configuration:
文件 → 设置 → Python 解释器, make sure it is set correctly.
Q2: How do I delete a project?
PyCharm does not delete project files automatically; you must do it manually:
-
Close the project (
文件 → 关闭项目). -
Delete the project folder in a file manager (such as Windows File Explorer).
**Q3: How do I back up / share a project?**
-
Recommended approach: use Git (PyCharm has built-in Git support).
-
Manual approach: copy the project folder (but it is recommended to exclude
.idea/andvenv/).