I have a project with multiple Python modules, each of which has its own virtual environment.
Project Structure:
data-reader (Python module)
data_reader
reader.py
venv (virtual environment directory for data-reader)
requirements.txt
data-writer (Python module)
data_writer
writer.py
venv (virtual environment directory for data-writer)
requirements.txt
commons (Python module)
commons
utils.py
venv (virtual environment directory for commons)
requirements.txt
setup.py
I want to install commons
as a dependency in both modules: data-reader
and data-writer
and preferably as an editable project dependency.
I created setup.py
in commons and added the following requirement to the requirements.txt
in both modules:
-e commons
When I activate the virtual environment for one of the modules and install its requirements I can run scripts from commons
in the Python interpreter using the terminal, which is the expected and desired outcome, but in the Intellij IDEA
IDE, I get an error underlining the import statement and with this error message: Unresolved reference 'commons'
from commons import utils
I don't know if it is a problem in IDEA
or in the approach I am using.
- What is the recommended way to add and manage such dependencies?
- Is adding this dependency as an editable project one a good idea in the first place or there is other recommended approaches?