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 project B, that imports python packages from project A, but PyCharm can't find the source.
I've marked the directories with python packages in project A as source directories in PyCharm, and indeed other code in project A can lookup these python packages. But these source directories don't appear to be part of the lookup table for other projects in the same window.
Is there any way in PyCharm to make one project recognize directories from another project as a source directory?
Changing the Current Working Directory in Python To change the current working directory in Python, use the chdir() method. The method accepts one argument, the path to the directory to which you want to change. The path argument can be absolute or relative.
The PyCharm system directory contains caches and local history files. You can change the location of the PyCharm system directory using the idea.
You have to tell Pycharm to use Project A as another "Content Root" for Project B.
+ Add Content Root
at the right panelSelect content root directory
Now, you'll see Project A is listed at the right panel.
Ctrl
and click left mouse button
to select multiple entities.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.
Pycharm 2020.2 - just in your project, File -> Open select project whitch you want attach. And choose 'Attach' in Open project window.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With