Wednesday, 23 June 2021

Installing Python libraries in the Visual Studio Code container

I can edit python code in a folder located in a Docker Volume. I use Visual Studio Code and in general lines it works fine.

The only problem that I have is that the libraries (such as pandas and numpy) are not installed in the container that Visual Studio creates to mount the volume, so I get warning errors.

How to install these libraries in Visual Studio Code container?

** UPDATE **

This is my application Dockerfile, see that the libraries are included in the image, not the volume:

FROM daskdev/dask

RUN /opt/conda/bin/conda create -p /pyenv -y
RUN /opt/conda/bin/conda install -p /pyenv scikit-learn flask waitress gunicorn \
    pytest apscheduler matplotlib pyodbc -y
RUN /opt/conda/bin/conda install -p /pyenv -c conda-forge dask-ml pyarrow -y
RUN /opt/conda/bin/conda install -p /pyenv pip -y
RUN /pyenv/bin/pip install pydrill 

And the application is started with docker compose:

version: '3'

services:   

  web:
    image: img-python
    container_name: cont_flask
    volumes:
      - vol_py_code:/code
    ports:
      - "5000:5000"
    working_dir: /code
    entrypoint:
      - /pyenv/bin/gunicorn
    command:
      - -b 0.0.0.0:5000
      - --reload
      - app.frontend.app:app


from Installing Python libraries in the Visual Studio Code container

No comments:

Post a Comment