python内核在运行Docker容器时找不到Vscode

发布于 2025-01-25 19:57:14 字数 1183 浏览 2 评论 0原文

我正在尝试构建一个Docker映像,以进行调试,该模块在Vscocde中具有许多奇怪的依赖项。

我正在使用下面的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)"


当交互式运行图像时(如我的测试所建议)时,我可以成功运行:

python

但是,当我使用vscode远程容器和docker扩展名时+p 要运行远程containers:连接到运行容器

我无法通过在.py文件中执行代码来访问Python,并且如果我尝试使用.ipynb它告诉我我需要从“市场”中安装一个python内核。

基本上,VSCODE似乎与默认的Python内核没有连接。

我是新手,所以任何建议都会有所帮助!

I am trying to build a docker image to do debuging of a module that has lots of odd dependencies in vscocde.

I am using the dockerfile below to build the image:

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

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'.

Basically, vscode doesn't seem to have a connection to the default python kernel.

I am new to this, so any suggestions would be helpful!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

苍风燃霜 2025-02-01 19:57:14

您可以尝试基于 document

You can try to create and update a dockerfile based on the document

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文