Reputation: 16841
I have a Python application that I am developing in PyCharm Professional 2022.1.2 on Windows. I am using Poetry to manage my application and all package dependencies are listed in pyproject.toml
.
I would like to debug my application in Linux in a Docker container.
I've successfully set up a Remote Docker Interpreter based on documentation from JetBrains but when I try to run my application with it, I get this error:
70a53fea2bae:python -u /opt/project/myapp/cli/main.py serve
Traceback (most recent call last):
File "/opt/project/myapp/cli/main.py", line 7, in <module>
from myapp.dashboard import serve_dashboard
File "/opt/project/myapp/__init__.py", line 1, in <module>
from myapp.pipeline.api.data_reader import ExperimentReader
File "/opt/project/myapp/pipeline/api/data_reader.py", line 7, in <module>
from pandas import DataFrame
ModuleNotFoundError: No module named 'pandas'
Process finished with exit code 1
This makes me think that my application's package dependencies have not been installed inside the container.
How can I get PyCharm to install my dependencies (poetry install
presumably?) before running my app?
Upvotes: 0
Views: 989
Reputation: 199
The image you're using python:3.9.13-buster
is delivered without your extra dependencies. It is like a raw python installation on your local machine.
If you want to enhance it with your custom dependencies, you need to create a Dockerfile
which instructs docker
to build a new image based on python:3.9.13-buster
but with your extra dependencies (pandas
) preinstalled.
I'd suggest starting with this tutorial to get familiar with how docker works and how to define custom images using Dockerfile
and how to build & use them.
PS Here is some SO answer with example how such Dockerfile
for image which installs dependencies defined using poetry's pyproject.toml
may look like: https://stackoverflow.com/a/71786211/6082882 but again I'd suggest starting with learning docker fundamentals.
Upvotes: 1