I have a folder structure as follows:
python_projects
|
|- common_tools
| |- __init__.py
| |- some_functions.py
|
|- some_project
|- main.py
I currently import some_functions.py into main.py as follows, similar to what is described here:
import sys
import os
CURRENT_DIR = os.path.dirname(os.path.realpath(__file__))
sys.path.insert(0, os.path.dirname(CURRENT_DIR))
from common_tools import some_functions
This seems to work correctly and Python raises no errors when calling some_functions.a_function(). However, Pycharm doesn't seem to recognise the references to common_tools or some_functions, and thus doesn't automatically suggest a_function() when I type some_functions.
I have seen answers which handle including modules within some_project, but I plan to use common_tools for several other projects (which would be located as siblings to some_project) and would prefer to keep the folder structure in such a way that I can set up each individual project to access common_tools without having to have a separate copy of the module within each project folder.
I have tried adding various folders to Content Root and/or marking them as Sources..., but I haven't found a combination that seems to work yet. What is the best way to handle this?