RError.com

RError.com Logo RError.com Logo

RError.com Navigation

  • 主页

Mobile menu

Close
  • 主页
  • 系统&网络
    • 热门问题
    • 最新问题
    • 标签
  • Ubuntu
    • 热门问题
    • 最新问题
    • 标签
  • 帮助
主页 / 问题 / 1601758
Accepted
polymamylop
polymamylop
Asked:2024-12-06 09:17:20 +0000 UTC2024-12-06 09:17:20 +0000 UTC 2024-12-06 09:17:20 +0000 UTC

创建 Docker 容器时遇到的问题

  • 772

我安装了 OpenAi Universe

cd ~ git clone https://github.com/openai/universe.git
cd universe
pip install -e .

安装过程中出现这样的消息:

Obtaining file:///Users/user/universe
  Preparing metadata (setup.py) ... done
Requirement already satisfied: universe in /Users/user/universe (0.21.5)
Requirement already satisfied: autobahn>=0.16.0 in /opt/anaconda3/envs/universe2/lib/python3.10/site-packages (from universe==0.21.5) (24.4.2)
Requirement already satisfied: docker-py==1.10.3 in /opt/anaconda3/envs/universe2/lib/python3.10/site-packages (from universe==0.21.5) (1.10.3)
Requirement already satisfied: docker-pycreds==0.2.1 in /opt/anaconda3/envs/universe2/lib/python3.10/site-packages (from universe==0.21.5) (0.2.1)
Requirement already satisfied: fastzbarlight>=0.0.13 in /opt/anaconda3/envs/universe2/lib/python3.10/site-packages (from universe==0.21.5) (0.0.14)
Requirement already satisfied: go-vncdriver>=0.4.8 in /Users/danilabrikanov/go-vncdriver (from universe==0.21.5) (0.4.19)
Requirement already satisfied: gym>=0.8.1 in /opt/anaconda3/envs/universe2/lib/python3.10/site-packages (from universe==0.21.5) (0.26.2)
Requirement already satisfied: Pillow>=3.3.0 in /opt/anaconda3/envs/universe2/lib/python3.10/site-packages (from universe==0.21.5) (10.4.0)
Requirement already satisfied: PyYAML>=3.12 in /opt/anaconda3/envs/universe2/lib/python3.10/site-packages (from universe==0.21.5) (6.0.1)
Requirement already satisfied: six>=1.10.0 in /opt/anaconda3/envs/universe2/lib/python3.10/site-packages (from universe==0.21.5) (1.16.0)
Requirement already satisfied: twisted>=16.5.0 in /opt/anaconda3/envs/universe2/lib/python3.10/site-packages (from universe==0.21.5) (23.10.0)
Requirement already satisfied: ujson>=1.35 in /opt/anaconda3/envs/universe2/lib/python3.10/site-packages (from universe==0.21.5) (5.10.0)
Requirement already satisfied: requests<2.11,>=2.5.2 in /opt/anaconda3/envs/universe2/lib/python3.10/site-packages (from docker-py==1.10.3->universe==0.21.5) (2.10.0)
Requirement already satisfied: websocket-client>=0.32.0 in /opt/anaconda3/envs/universe2/lib/python3.10/site-packages (from docker-py==1.10.3->universe==0.21.5) (1.8.0)
Requirement already satisfied: txaio>=21.2.1 in /opt/anaconda3/envs/universe2/lib/python3.10/site-packages (from autobahn>=0.16.0->universe==0.21.5) (23.1.1)
Requirement already satisfied: cryptography>=3.4.6 in /opt/anaconda3/envs/universe2/lib/python3.10/site-packages (from autobahn>=0.16.0->universe==0.21.5) (43.0.0)
Requirement already satisfied: hyperlink>=21.0.0 in /opt/anaconda3/envs/universe2/lib/python3.10/site-packages (from autobahn>=0.16.0->universe==0.21.5) (21.0.0)
Requirement already satisfied: setuptools in /opt/anaconda3/envs/universe2/lib/python3.10/site-packages (from autobahn>=0.16.0->universe==0.21.5) (75.1.0)
Requirement already satisfied: numpy in /opt/anaconda3/envs/universe2/lib/python3.10/site-packages (from go-vncdriver>=0.4.8->universe==0.21.5) (1.26.4)
Requirement already satisfied: cloudpickle>=1.2.0 in /opt/anaconda3/envs/universe2/lib/python3.10/site-packages (from gym>=0.8.1->universe==0.21.5) (3.0.0)
Requirement already satisfied: gym_notices>=0.0.4 in /opt/anaconda3/envs/universe2/lib/python3.10/site-packages (from gym>=0.8.1->universe==0.21.5) (0.0.8)
Requirement already satisfied: attrs>=21.3.0 in /opt/anaconda3/envs/universe2/lib/python3.10/site-packages (from twisted>=16.5.0->universe==0.21.5) (23.1.0)
Requirement already satisfied: automat>=0.8.0 in /opt/anaconda3/envs/universe2/lib/python3.10/site-packages (from twisted>=16.5.0->universe==0.21.5) (20.2.0)
Requirement already satisfied: constantly>=15.1 in /opt/anaconda3/envs/universe2/lib/python3.10/site-packages (from twisted>=16.5.0->universe==0.21.5) (23.10.4)
Requirement already satisfied: incremental>=22.10.0 in /opt/anaconda3/envs/universe2/lib/python3.10/site-packages (from twisted>=16.5.0->universe==0.21.5) (22.10.0)
Requirement already satisfied: typing-extensions>=4.2.0 in /opt/anaconda3/envs/universe2/lib/python3.10/site-packages (from twisted>=16.5.0->universe==0.21.5) (4.11.0)
Requirement already satisfied: zope-interface>=5 in /opt/anaconda3/envs/universe2/lib/python3.10/site-packages (from twisted>=16.5.0->universe==0.21.5) (5.4.0)
Requirement already satisfied: cffi>=1.12 in /opt/anaconda3/envs/universe2/lib/python3.10/site-packages (from cryptography>=3.4.6->autobahn>=0.16.0->universe==0.21.5) (1.17.1)
Requirement already satisfied: idna>=2.5 in /opt/anaconda3/envs/universe2/lib/python3.10/site-packages (from hyperlink>=21.0.0->autobahn>=0.16.0->universe==0.21.5) (3.7)
Requirement already satisfied: pycparser in /opt/anaconda3/envs/universe2/lib/python3.10/site-packages (from cffi>=1.12->cryptography>=3.4.6->autobahn>=0.16.0->universe==0.21.5) (2.21)
Installing collected packages: universe
  Attempting uninstall: universe
    Found existing installation: universe 0.21.5
    Uninstalling universe-0.21.5:
      Successfully uninstalled universe-0.21.5
  DEPRECATION: Legacy editable install of universe==0.21.5 from file:///Users/user/universe (setup.py develop) is deprecated. pip 25.0 will enforce this behaviour change. A possible replacement is to add a pyproject.toml or enable --use-pep517, and use setuptools >= 64. If the resulting installation is not behaving as expected, try using --config-settings editable_mode=compat. Please consult the setuptools documentation for more information. Discussion can be found at https://github.com/pypa/pip/issues/11457
  Running setup.py develop for universe
Successfully installed universe

接下来我需要创建一个 Docker 镜像:

docker build -t universe .

运行该命令后,创建时出现错误:

[+] Building 3.2s (10/18)                                  docker:desktop-linux
 => [internal] load build definition from Dockerfile                       0.0s
 => => transferring dockerfile: 1.48kB                                     0.0s
 => [internal] load metadata for docker.io/library/ubuntu:16.04            3.0s
 => [auth] library/ubuntu:pull token for registry-1.docker.io              0.0s
 => [internal] load .dockerignore                                          0.0s
 => => transferring context: 66B                                           0.0s
 => [ 1/13] FROM docker.io/library/ubuntu:16.04@sha256:1f1a2d56de1d604801  0.0s
 => [internal] load build context                                          0.0s
 => => transferring context: 13.44kB                                       0.0s
 => CACHED [ 2/13] RUN apt-get update     && apt-get install -y libav-too  0.0s
 => CACHED [ 3/13] RUN true                                                0.0s
 => CACHED [ 4/13] RUN ln -sf /usr/bin/pip3 /usr/local/bin/pip     && ln   0.0s
 => ERROR [ 5/13] RUN pip install gym[all]                                 0.2s
------                                                                          
 > [ 5/13] RUN pip install gym[all]:                                            
0.164 Traceback (most recent call last):                                        
0.164   File "/usr/local/bin/pip", line 7, in <module>                          
0.164     from pip._internal.cli.main import main                               
0.164   File "/usr/local/lib/python3.5/dist-packages/pip/_internal/cli/main.py", line 67
0.164     sys.stderr.write(f"ERROR: {exc}")
0.164                                    ^
0.164 SyntaxError: invalid syntax
------
Dockerfile:36
--------------------
  34 |     
  35 |     # Install gym
  36 | >>> RUN pip install gym[all]
  37 |     
  38 |     # Get the faster VNC driver
--------------------
ERROR: failed to solve: process "/bin/sh -c pip install gym[all]" did not complete successfully: exit code: 1

View build details: docker-desktop://dashboard/build/desktop-linux/desktop-linux/lzvq2rrk75dfl8bh6pc8k4wsr

我能做些什么来解决这个问题,我读了 Sudharsan Ravichandiran 的书《Python 中的深度强化学习》。因为这个问题我无法继续阅读。

Dockerfile:

FROM ubuntu:16.04

RUN apt-get update \
    && apt-get install -y libav-tools \
    python3-numpy \
    python3-scipy \
    python3-setuptools \
    python3-pip \
    libpq-dev \
    libjpeg-dev \
    curl \
    cmake \
    swig \
    python3-opengl \
    libboost-all-dev \
    libsdl2-dev \
    wget \
    unzip \
    git \
    golang \
    net-tools \
    iptables \
    libvncserver-dev \
    software-properties-common \
    && apt-get clean \
    && rm -rf /var/lib/apt/lists/*

ARG BASE_COMMAND="true"
RUN $BASE_COMMAND

RUN ln -sf /usr/bin/pip3 /usr/local/bin/pip \
    && ln -sf /usr/bin/python3 /usr/local/bin/python \
    && pip install -U pip

# Install gym
RUN pip install gym[all]

# Get the faster VNC driver
RUN pip install go-vncdriver>=0.4.0

# Install pytest (for running test cases)
RUN pip install pytest

# Force the container to use the go vnc driver
ENV UNIVERSE_VNCDRIVER='go'

WORKDIR /usr/local/universe/

# Cachebusting
COPY ./setup.py ./
COPY ./tox.ini ./

RUN pip install -e .

# Upload our actual code
COPY . ./

# Just in case any python cache files were carried over from the source directory, remove them
RUN py3clean .
python
  • 1 1 个回答
  • 30 Views

1 个回答

  • Voted
  1. Best Answer
    Pak Uula
    2024-12-08T01:47:51Z2024-12-08T01:47:51Z

    更新

    编译好的docker将无法运行。从Python 3.7开始,标识符async是一个关键字,并且在源代码中universal有一个赋值async = что-то-там()。此时执行崩溃了。

    我尝试在 3.6 中编译 - 它不起作用gym。

    显然你需要找到一本更新的书。

    不工作 试试这个 Dockerfile。它基于较新版本的 Ubuntu 构建,并从 python 包集合中收集最新版本的 numpy 和 scipy。

    FROM ubuntu:20.04
    
    RUN apt-get clean
    RUN apt-get update 
    
    RUN apt install python3 python3-pip -y
    RUN /usr/bin/python3 -m pip install -U pip
    RUN /usr/bin/python3 -m pip install setuptools
    RUN /usr/bin/python3 -m pip install numpy scipy 
    
    ENV DEBIAN_FRONTEND noninteractive
    RUN apt install tzdata -y
    
    RUN apt-get install -y ffmpeg \
        libpq-dev \
        libjpeg-dev \
        curl \
        cmake \
        swig \
    # python3-numpy \
    # python3-scipy \
    # python3-setuptools \
    # python3-pip \
        python3-opengl \
        libboost-all-dev \
        libsdl2-dev \
        wget \
        unzip \
        git \
        golang \
        net-tools \
        iptables \
        libvncserver-dev \
        software-properties-common
    
    
    RUN apt-get clean 
    RUN rm -rf /var/lib/apt/lists/*
    
    RUN ln -sf /usr/bin/pip3 /usr/local/bin/pip \
        && ln -sf /usr/bin/python3 /usr/local/bin/python \
        && pip install -U pip
    
    # Install gym
    RUN pip install gym[all]
    
    # Get the faster VNC driver
    RUN pip install go-vncdriver>=0.4.0
    
    # Install pytest (for running test cases)
    RUN pip install pytest
    
    # Force the container to use the go vnc driver
    ENV UNIVERSE_VNCDRIVER 'go'
    
    WORKDIR /usr/local/universe/
    
    # Cachebusting
    COPY ./setup.py ./
    COPY ./tox.ini ./
    
    RUN pip install -e .
    
    # Upload our actual code
    COPY . ./
    
    # Just in case any python cache files were carried over from the source directory, remove them
    RUN py3clean .
    

    我不知道你会用这个镜像做什么,也不知道由于 python 版本不一致可能会出现什么问题,但至少它是构建出来的。

    • 1

相关问题

  • 是否可以以某种方式自定义 QTabWidget?

  • telebot.anihelper.ApiException 错误

  • Python。检查一个数字是否是 3 的幂。输出 无

  • 解析多个响应

  • 交换两个数组的元素,以便它们的新内容也反转

Sidebar

Stats

  • 问题 10021
  • Answers 30001
  • 最佳答案 8000
  • 用户 6900
  • 常问
  • 回答
  • Marko Smith

    我看不懂措辞

    • 1 个回答
  • Marko Smith

    请求的模块“del”不提供名为“default”的导出

    • 3 个回答
  • Marko Smith

    "!+tab" 在 HTML 的 vs 代码中不起作用

    • 5 个回答
  • Marko Smith

    我正在尝试解决“猜词”的问题。Python

    • 2 个回答
  • Marko Smith

    可以使用哪些命令将当前指针移动到指定的提交而不更改工作目录中的文件?

    • 1 个回答
  • Marko Smith

    Python解析野莓

    • 1 个回答
  • Marko Smith

    问题:“警告:检查最新版本的 pip 时出错。”

    • 2 个回答
  • Marko Smith

    帮助编写一个用值填充变量的循环。解决这个问题

    • 2 个回答
  • Marko Smith

    尽管依赖数组为空,但在渲染上调用了 2 次 useEffect

    • 2 个回答
  • Marko Smith

    数据不通过 Telegram.WebApp.sendData 发送

    • 1 个回答
  • Martin Hope
    Alexandr_TT 2020年新年大赛! 2020-12-20 18:20:21 +0000 UTC
  • Martin Hope
    Alexandr_TT 圣诞树动画 2020-12-23 00:38:08 +0000 UTC
  • Martin Hope
    Air 究竟是什么标识了网站访问者? 2020-11-03 15:49:20 +0000 UTC
  • Martin Hope
    Qwertiy 号码显示 9223372036854775807 2020-07-11 18:16:49 +0000 UTC
  • Martin Hope
    user216109 如何为黑客设下陷阱,或充分击退攻击? 2020-05-10 02:22:52 +0000 UTC
  • Martin Hope
    Qwertiy 并变成3个无穷大 2020-11-06 07:15:57 +0000 UTC
  • Martin Hope
    koks_rs 什么是样板代码? 2020-10-27 15:43:19 +0000 UTC
  • Martin Hope
    Sirop4ik 向 git 提交发布的正确方法是什么? 2020-10-05 00:02:00 +0000 UTC
  • Martin Hope
    faoxis 为什么在这么多示例中函数都称为 foo? 2020-08-15 04:42:49 +0000 UTC
  • Martin Hope
    Pavel Mayorov 如何从事件或回调函数中返回值?或者至少等他们完成。 2020-08-11 16:49:28 +0000 UTC

热门标签

javascript python java php c# c++ html android jquery mysql

Explore

  • 主页
  • 问题
    • 热门问题
    • 最新问题
  • 标签
  • 帮助

Footer

RError.com

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

帮助

© 2023 RError.com All Rights Reserve   沪ICP备12040472号-5