简体   繁体   English

Python kernel 在运行 docker 容器时未被 vscode 找到

[英]Python kernel not found by vscode when running docker container

I am trying to build a docker image to do debuging of a module that has lots of odd dependencies in vscocde.我正在尝试构建一个 docker 图像来调试一个在 vscocde 中有很多奇怪依赖项的模块。

I am using the dockerfile below to build the image:我正在使用下面的 dockerfile 来构建图像:

FROM ubuntu:20.04
USER root

RUN apt update -y && apt upgrade -y && \
    apt install -y software-properties-common && \
    add-apt-repository ppa:ubuntugis/ppa && \
    apt update -y && apt install -y \
    gdal-bin \
    geotiff-bin \
    git \
    libgdal-dev \
    libgl1 \
    libspatialindex-dev \ 
    wget \
    python-is-python3 \
    pip \
    g++ 

RUN pip install Cython numpy  

RUN git clone https://github.com/jgrss/geowombat.git

RUN pip install -r /geowombat/requirements.txt

RUN  pip install sklearn-xarray  pip-tools rtree ipykernel

RUN python -c "import geowombat as gw"
RUN python -c "import rasterio;from rasterio.crs import CRS; cc = CRS.from_epsg(4326)"


When running the image interactively (as my tests suggest) I can successfully run:当以交互方式运行图像时(如我的测试所示),我可以成功运行:

python

However when I use vscode remote containers and docker extension to "attach vscode" or use shift+cntr+p to run Remote-Containers: Attach to running container但是,当我使用 vscode 远程容器和 docker 扩展来“附加 vscode”或使用shift+cntr+p运行Remote-Containers: Attach to running container

I am unable to access python by executing code in an .py file and if I try using an .ipynb it informs me I need to install a python kernel from 'the marketplace'.我无法通过在.py文件中执行代码来访问 python,如果我尝试使用.ipynb ,它会通知我需要从“市场”安装 python kernel。

Basically, vscode doesn't seem to have a connection to the default python kernel.基本上,vscode似乎没有连接到默认的python kernel。

I am new to this, so any suggestions would be helpful!我对此很陌生,所以任何建议都会有所帮助!

You can try to create and update a dockerfile based on thedocument你可以尝试根据文档创建和更新一个dockerfile

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM