Running jupyter notebook with remote Docker interpreter
已回答
Hello,
I cannot manage to run Jupyter notebook with a remote Docker interpreter. The notebook run configuration keeps asking: "Please select local python interpreter"... I have PyCharm Pro 2017.2.3.
The Remote interpreter works perfectly when I run a standard python program. It just doesn't work for notebooks. If I "force execute" the run configuration, it runs the server but I cannot manage to connect the notebook (it works through the provided link in a browser though but not with the notebook "Run cell" button) even though I can see the following log:
c4ae62f9f886:/usr/bin/python3 -u /opt/.pycharm_helpers/pycharm/pycharm_load_entry_point.py notebook --no-browser --ip 0.0.0.0 --port 8888 --port-retries=0 --allow-root
[TerminalIPythonApp] WARNING | Subcommand `ipython notebook` is deprecated and will be removed in future versions.
[TerminalIPythonApp] WARNING | You likely want to use `jupyter notebook` in the future
[I 15:01:19.080 NotebookApp] Writing notebook server cookie secret to /root/.local/share/jupyter/runtime/notebook_cookie_secret
[I 15:01:19.101 NotebookApp] Serving notebooks from local directory: /opt/project
[I 15:01:19.101 NotebookApp] 0 active kernels
[I 15:01:19.101 NotebookApp] The Jupyter Notebook is running at:
[I 15:01:19.101 NotebookApp] http://0.0.0.0:8888/?token=6ba64aba0f80d6ea1d4b0f35283530615b58778a7934e1bf
[I 15:01:19.101 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
[C 15:01:19.102 NotebookApp]
Copy/paste this URL into your browser when you connect for the first time,
to login with a token:
http://0.0.0.0:8888/?token=6ba64aba0f80d6ea1d4b0f35283530615b58778a7934e1bf
- Here is my launch configuration (I tried with 127.0.0.1 and * too):

- Here is my docker-compose file:
version: '2'
services:
python:
build: .
command: /usr/bin/python3
devices:
- "/dev/snd:/dev/snd"
environment:
- DISPLAY=$DISPLAY
image: gaia:latest
port:
- "127.0.0.1:8888:8888"
privileged: true
volumes:
- /dev/dri:/dev/dri
- /tmp/.X11-unix:/tmp/.X11-unix
- /dev/shm:/dev/shm
- /etc/machine-id:/etc/machine-id
- /run/dbus:/run/dbus
- And my Dockerfile looks like this:
ARG BASE_IMAGE=ubuntu:artful
FROM $BASE_IMAGE
# System libraries
RUN apt-get update \
&& apt-get install --yes --no-install-recommends \
build-essential \
cmake \
curl \
fort77 \
gfortran \
git \
gstreamer1.0-alsa \
gstreamer1.0-clutter \
gstreamer1.0-fluendo-mp3 \
gstreamer1.0-libav \
gstreamer1.0-nice \
gstreamer1.0-plugins-bad \
gstreamer1.0-plugins-base \
gstreamer1.0-plugins-base-apps \
gstreamer1.0-plugins-good \
gstreamer1.0-plugins-ugly \
gstreamer1.0-pulseaudio \
gstreamer1.0-tools \
gstreamer1.0-vaapi \
gstreamer1.0-x \
jq \
libatlas-base-dev \
libavcodec-dev \
libavformat-dev \
libdc1394-22-dev \
libboost-python-dev \
libjpeg-dev \
libgstreamer1.0-dev \
libgstreamer-plugins-base1.0-dev \
libgtk2.0-dev \
libgtk-3-dev \
libpng-dev \
libswscale-dev \
libtbb2 \
libtbb-dev \
libtiff-dev \
libv4l-dev \
libx11-dev \
libx264-dev \
libxvidcore-dev \
pkg-config \
python3-dev \
python3-numpy \
python3-pip \
python3-scipy \
python3-setuptools \
python3-wheel \
vim \
wget \
&& apt-get -y autoclean \
&& apt-get -y autoremove \
&& rm -rf /var/lib/apt/lists/*
# OpenCV
RUN cd /root \
&& wget https://github.com/opencv/opencv/archive/3.3.0.tar.gz -O opencv.tar.gz \
&& tar zxf opencv.tar.gz && rm -f opencv.tar.gz \
&& wget https://github.com/opencv/opencv_contrib/archive/3.3.0.tar.gz -O contrib.tar.gz \
&& tar zxf contrib.tar.gz && rm -f contrib.tar.gz \
&& cd opencv-3.3.0 \
&& mkdir build \
&& cd build \
&& cmake \
-D BUILD_DOCS=OFF \
-D BUILD_EXAMPLES=OFF \
-D BUILD_TESTS=OFF \
-D BUILD_opencv_python2=OFF \
-D BUILD_opencv_python3=ON \
-D CMAKE_BUILD_TYPE=Release \
-D CMAKE_INSTALL_PREFIX=/usr/local \
-D CMAKE_CXX_FLAGS="-O3 -funsafe-math-optimizations" \
-D CMAKE_C_FLAGS="-O3 -funsafe-math-optimizations" \
-D INSTALL_PYTHON_EXAMPLES=OFF \
-D OPENCV_EXTRA_MODULES_PATH=/root/opencv_contrib-3.3.0/modules \
-D WITH_JASPER=OFF \
-D WITH_LIBV4L=ON \
-D WITH_TBB=ON \
.. \
&& make \
&& make install \
&& cd /root \
&& rm -rf opencv-3.3.0 opencv_contrib-3.3.0 \
&& ldconfig
# Dlib
RUN wget http://dlib.net/files/dlib-19.7.tar.bz2 \
&& tar xvf dlib-19.7.tar.bz2 \
&& cd dlib-19.7/ \
&& mkdir build \
&& cd build \
&& cmake \
-D CMAKE_BUILD_TYPE=Release \
-D CMAKE_INSTALL_PREFIX=/usr/local \
-D USE_AVX_INSTRUCTIONS=1 \
.. \
&& cmake --build . --config Release \
&& make install \
&& ldconfig \
&& cd .. \
&& python3 setup.py install --yes USE_AVX_INSTRUCTIONS
# Python env
RUN pip3 install --help
RUN python3 -m pip install --upgrade pip \
&& pip3 install --user \
face_recognition \
imutils \
ipython \
jupyter \
matplotlib \
numpy \
pandas \
scikit-image \
scikit-learn
ENV PATH="~/.local/bin:${PATH}"
What am I doing wrong?
请先登录再写评论。
The only related bug I found is the following: https://youtrack.jetbrains.com/issue/PY-24739
I also have a weird error in the logs (knowing that I'm on Linux Arch):
Hi! remote interpreters are not supported for Jupyter Notebooks for now unfortunately. Corresponding feature request: PY-26328.
Thanks for the ref. That would be great to have that!