In PyCharm, how do you add a directory from one project as a source to another project?
You have to tell Pycharm to use Project A as another "Content Root" for Project B.
- From the upper bar, go to File -> Settings... -> Project: [yourprojectnamehere] -> Project Structure.
- Click on
+ Add Content Root
at the right panel - Select the Project A folder from the popup named
Select content root directory
- Click OK
Now, you'll see Project A is listed at the right panel.
- Click on Project A from the right panel
- Now, the content of project A is listed. Select the ones you want to be included as source. You can hold
Ctrl
and clickleft mouse button
to select multiple entities. - Click
Sources
from the upper bar to assign the selected entities as Source.
Now you should see Source Folders at the right panel.
UPDATE: As of at least Pycharm 2019.1.3, this seems to have changed, to be simpler thankfully.
- From the upper bar, go to File -> Settings... -> Project: [yourprojectnamehere] -> Project Dependencies.
- Select your project, and then click the checkboxes for each other project it's dependent on.
Pycharm 2020.2 - just in your project, File -> Open select project whitch you want attach. And choose 'Attach' in Open project window.