Add Path to Project in PyCharm
| Introduction | |
| Add path to project | |
| Related articles |
Intro
In this article you can learn how to manually add paths to the PyCharm interpreter.
Add path to project
In order for PyCharm to find all parts of the project, you need to add the path to the root directory to the interpreter.
The interpreter is usually listed in the lower right corner.
I also recommend making sure that the directories contain the files
__init__.py
- despite the fact that some sources say that its presence is not necessary, I still see a difference in the behavior of PyCharm.
If PyCharm opens an empty directory or a directory without a virtual environment, it will automatically connect to a default interpreter of the following type:
C:\Users\User\AppData\Local\Programs\Python\Python312\python.exe
https://aredel.com
If a virtual environment has already been created in the directory, PyCharm will pick it up by default. Then the path to Python will be something like this:
C:\DEV\pych_path_demo\venv\Scripts\python.exe
https://aredel.com
By default, importing modules should work by listing directories through a dot
https://aredel.com
If for some reason the modules are not found, you can add the project root or another directory to the
interpreter path.
First, you need to click on the lower right corner.
https://aredel.com
Then select the desired interpreter
https://aredel.com
Expand list of interpreters
https://aredel.com
Select Show All…
https://aredel.com
Expand tree
https://aredel.com
Click +
https://aredel.com
Specify the path and click OK
https://aredel.com
The path will appear in the list with the remark added by user
https://aredel.com
| PyCharm: IDE | |
| Install | |
| Add Path to Project | |
| Editor Basics | |
| Python | |
| Add Selenium to PyCharm |