我找到了一个基本的firefox独立映像,我试图在docker容器中使用带有geckodriver的selenium运行脚本,我试图从dockerfile安装要求,但得到ModuleNotFoundError: No module named 'selenium'
这是我的Dockerfile:
From selenium/node-firefox:3.141.59-iron
# Set buffered environment variable
ENV PYTHONUNBUFFERED 1
# Set the working directory to /app
USER root
RUN mkdir /app
WORKDIR /app
EXPOSE 80
# Install packacges needed for crontab and selenium
RUN apt-get update && apt-get install -y sudo libpulse0 pulseaudio software-properties-common libappindicator1 fonts-liberation python-pip virtualenv
RUN apt-get install binutils libproj-dev gdal-bin cron nano -y
# RUN virtualenv -p /usr/bin/python3.6 venv36
# RUN . venv36/bin/activate
# Install any needed packages specified in requirements.txt
ADD requirements.txt /app/
RUN pip install -r requirements.txt
ADD . /app/
ENTRYPOINT ["/bin/bash"]
我希望我的脚本能够运行,我不确定为什么在交互式shell中使用Python2.7,我认为selenium docker映像随附了3.6,并且已经安装了selenium
答案 0 :(得分:2)
您的容器随附python
(Python 2)和python3
。只是python
默认为2.7实例。您可以通过发出以下命令来更改此行为:
RUN alias python=python3
在您的Dockerfile