当前位置:   article > 正文

Dockerfile 在11.2.1-cudnn8-runtime-ubuntu18.04-conda基础安装qt5并显示pyqt5应用_conda安装qt

conda安装qt

编写一个简单的pyqt5界面App.py

import sys
from PyQt5.QtWidgets import QApplication, QWidget, QLabel, QPushButton, QVBoxLayout
class MyWindow(QWidget):
    def __init__(self):
        super().__init__()
        self.initUI()
    def initUI(self):
        # 创建标签
        label = QLabel('PyQt5界面', self)
        label.move(50, 50)
        # 创建按钮
        button = QPushButton('点击', self)
        button.move(50, 100)
        button.clicked.connect(self.buttonClicked)
        # 创建布局
        vbox = QVBoxLayout()
        vbox.addWidget(label)
        vbox.addWidget(button)
        # 将布局应用到窗口
        self.setLayout(vbox)
        # 设置窗口大小和标题
        self.setGeometry(300, 300, 300, 200)
        self.setWindowTitle('PyQt5界面')
        self.show()
    def buttonClicked(self):
        # 按钮点击事件
        print('按钮被点击')
if __name__ == '__main__':
    app = QApplication(sys.argv)
    window = MyWindow()
    sys.exit(app.exec_())
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31

再次基础上运行Dockerfile脚本

FROM yutianchi/11.2.1-cudnn8-runtime-ubuntu18.04-conda:1.0.0
USER root
RUN sed -i s@/archive.ubuntu.com/@/mirrors.aliyun.com/@g /etc/apt/sources.list
RUN apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 'A4B469963BF863CC'


RUN  apt-get update
ENV  TIME_ZONE Asia/Shanghai
ENV  DEBIAN_FRONTEND=noninteractive
ENV  LIBGL_ALWAYS_INDIRECT=1

RUN  apt-get install      ffmpeg  -y
RUN  apt-get install      libgl1-mesa-glx -y
RUN  apt-get install      libxss1 -y
RUN  apt-get install      libappindicator1 -y
RUN  apt-get install      libindicator7 -y
RUN  apt-get install      libjpeg8-dev -y
RUN  apt-get install      libpng-dev -y
RUN  apt-get install      libtiff5-dev -y
RUN  apt-get install      zlib1g-dev -y
RUN  apt-get install      libleptonica-dev -y
RUN  apt-get install      libtesseract-dev -y
RUN  apt-get install      tesseract-ocr -y
RUN  apt-get install      fonts-liberation -y
RUN  apt-get install      libappindicator3-1 -y
RUN  apt-get install      libasound2 -y
RUN  apt-get install      libnspr4 -y
RUN  apt-get install      libnss3 -y
RUN  apt-get install      xdg-utils -y
RUN  apt-get install      libcanberra-gtk-module -y
RUN  apt-get install      tcl-dev -y
RUN  apt-get install      tk-dev -y
RUN  apt-get install      python3-tk -y
RUN  apt-get install      dbus -y
RUN  apt-get install      locales -y
RUN  apt-get install      ttf-wqy-microhei -y
RUN  apt-get install      language-pack-zh-hans -y
RUN  apt-get install      python3-pyqt5 -y


ENV PATH /root/anaconda3/bin:$PATH
RUN conda update conda -y
RUN conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
RUN conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
RUN conda config --set show_channel_urls yes
RUN conda create -n ai-sport python=3.8 numpy pandas -y
SHELL ["conda", "run", "-n", "ai-sport", "/bin/bash", "-c"]
RUN pip install PyQt5 -i http://pypi.douban.com/simple/ --trusted-host pypi.douban.com
COPY .   . 

#sudo docker build -t='yutianchi/11.2.1-cudnn8-runtime-ubuntu18.04-conda-qt5:1.0.0' .
#xhost local:root
#sudo docker run --net=host --name ai-sport-app --gpus '"device=0"' --privileged --rm -it -v /dev:/dev -v /tmp/.X11-unix:/tmp/.X11-unix -e DISPLAY=$DISPLAY -u root   yutianchi/11.2.1-cudnn8-runtime-ubuntu18.04-conda-qt5:1.0.0

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54

构建镜像

sudo docker build -t='yutianchi/11.2.1-cudnn8-runtime-ubuntu18.04-conda-qt5:1.0.0' .
  • 1

给权限

xhost local:root
  • 1

运行容器

sudo docker run --net=host --name ai-sport-app --gpus '"device=0"' --privileged --rm -it -v /dev:/dev -v /tmp/.X11-unix:/tmp/.X11-unix -e DISPLAY=$DISPLAY -u root   yutianchi/11.2.1-cudnn8-runtime-ubuntu18.04-conda-qt5:1.0.0
  • 1

在这里插入图片描述

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/IT小白/article/detail/138671?site
推荐阅读
相关标签
  

闽ICP备14008679号