In PyCharm, how do you add a directory from one project as a source to another project?

前端 未结 2 1792
花落未央
花落未央 2020-12-28 13:08

I have several python projects started from git repos, all related to each other, that are all open in one PyCharm window.

I have python code in one project, call it

相关标签:
2条回答
  • 2020-12-28 13:32

    You have to tell Pycharm to use Project A as another "Content Root" for Project B.

    1. From the upper bar, go to File -> Settings... -> Project: [yourprojectnamehere] -> Project Structure.
    2. Click on + Add Content Root at the right panel
    3. Select the Project A folder from the popup named Select content root directory
    4. Click OK

    Now, you'll see Project A is listed at the right panel.

    1. Click on Project A from the right panel
    2. Now, the content of project A is listed. Select the ones you want to be included as source. You can hold Ctrl and click left mouse button to select multiple entities.
    3. 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.

    1. From the upper bar, go to File -> Settings... -> Project: [yourprojectnamehere] -> Project Dependencies.
    2. Select your project, and then click the checkboxes for each other project it's dependent on.
    0 讨论(0)
  • 2020-12-28 13:42

    Pycharm 2020.2 - just in your project, File -> Open select project whitch you want attach. And choose 'Attach' in Open project window.

    0 讨论(0)
提交回复
热议问题