错误:无法为opencv-python构建轮子,在anaconda env中安装gym时需要安装基于pyproject.toml的项目

问题描述 投票:0回答:1

我正在阅读《SUDHARSAN RAVICHANDIRAN - 使用Python进行强化学习 - _掌握强化和深度强化》书中的一章。有一个在单独的 anaconda 环境中使用 Gym 工具包的动手练习。在那里,我必须按照几个步骤在我的 Xubuntu 机器上安装必要的工具。

打开终端并输入以下命令来下载 Anaconda:
    wget https://repo.continuum.io/archive/Anaconda3-5.0.1-Linux-x86_64.sh
  1. 下载后,我们可以使用以下命令安装Anaconda:
  2. bash Anaconda3-5.0.1-Linux-x86_64.sh
  3. 使用以下命令创建虚拟环境并将我们的环境命名为 Universe:
  4. conda create --name universe python=3.6 anaconda
  5. 激活它:
  6. source activate universe
  7. 安装以下依赖项:
  8. sudo apt-get update sudo apt-get install golang libcupti-dev libjpeg-turbo8-dev make tmux htop chromium-browser git cmake zlib1g-dev libjpeg-dev xvfb libav-tools xorg-dev python-opengl libboost-all-dev libsdl2-dev swig conda install pip six libgcc swig conda install opencv
安装健身房:
    pip install gym==0.15.4
  1. 
    
  2. 然后花了相当长的时间并给出了以下日志

Collecting gym==0.15.4 Using cached gym-0.15.4-py3-none-any.whl Collecting opencv-python Using cached opencv-python-4.10.0.82.tar.gz (95.1 MB) Installing build dependencies ... done Getting requirements to build wheel ... done Preparing metadata (pyproject.toml) ... done Collecting pyglet<=1.3.2,>=1.2.0 Using cached pyglet-1.3.2-py2.py3-none-any.whl (1.0 MB) Requirement already satisfied: numpy>=1.10.4 in ./anaconda3/envs/universe/lib/python3.6/site-packages (from gym==0.15.4) (1.18.5) Requirement already satisfied: six in ./anaconda3/envs/universe/lib/python3.6/site-packages (from gym==0.15.4) (1.15.0) Requirement already satisfied: scipy in ./anaconda3/envs/universe/lib/python3.6/site-packages (from gym==0.15.4) (1.5.0) Collecting cloudpickle~=1.2.0 Using cached cloudpickle-1.2.2-py2.py3-none-any.whl (25 kB) Requirement already satisfied: future in ./anaconda3/envs/universe/lib/python3.6/site-packages (from pyglet<=1.3.2,>=1.2.0->gym==0.15.4) (0.18.2) Building wheels for collected packages: opencv-python Building wheel for opencv-python (pyproject.toml) ... - set of Installing commands ... Copying files from CMake output creating directory _skbuild/linux-x86_64-3.6/cmake-install/cv2 copying _skbuild/linux-x86_64-3.6/cmake-install/python/cv2/python-3/cv2.abi3.so -> _skbuild/linux-x86_64-3.6/cmake-install/cv2/cv2.abi3.so copying _skbuild/linux-x86_64-3.6/cmake-install/python/cv2/__init__.py -> _skbuild/linux-x86_64-3.6/cmake-install/cv2/__init__.py copying _skbuild/linux-x86_64-3.6/cmake-install/python/cv2/load_config_py2.py -> _skbuild/linux-x86_64-3.6/cmake-install/cv2/load_config_py2.py copying _skbuild/linux-x86_64-3.6/cmake-install/python/cv2/load_config_py3.py -> _skbuild/linux-x86_64-3.6/cmake-install/cv2/load_config_py3.py copying _skbuild/linux-x86_64-3.6/cmake-install/python/cv2/config.py -> _skbuild/linux-x86_64-3.6/cmake-install/cv2/config.py copying _skbuild/linux-x86_64-3.6/cmake-install/python/cv2/config-3.py -> _skbuild/linux-x86_64-3.6/cmake-install/cv2/config-3.py Traceback (most recent call last): File "/home/damiboy123/anaconda3/envs/universe/lib/python3.6/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 363, in <module> main() File "/home/damiboy123/anaconda3/envs/universe/lib/python3.6/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 345, in main json_out['return_val'] = hook(**hook_input['kwargs']) File "/home/damiboy123/anaconda3/envs/universe/lib/python3.6/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 262, in build_wheel metadata_directory) File "/tmp/pip-build-env-kazhr26h/overlay/lib/python3.6/site-packages/setuptools/build_meta.py", line 231, in build_wheel wheel_directory, config_settings) File "/tmp/pip-build-env-kazhr26h/overlay/lib/python3.6/site-packages/setuptools/build_meta.py", line 215, in _build_with_temp_dir self.run_setup() File "/tmp/pip-build-env-kazhr26h/overlay/lib/python3.6/site-packages/setuptools/build_meta.py", line 268, in run_setup self).run_setup(setup_script=setup_script) File "/tmp/pip-build-env-kazhr26h/overlay/lib/python3.6/site-packages/setuptools/build_meta.py", line 158, in run_setup exec(compile(code, __file__, 'exec'), locals()) File "setup.py", line 543, in <module> main() File "setup.py", line 316, in main cmake_source_dir=cmake_source_dir, File "/tmp/pip-build-env-kazhr26h/overlay/lib/python3.6/site-packages/skbuild/setuptools_wrap.py", line 683, in setup cmake_install_dir, File "setup.py", line 456, in _classify_installed_files_override raise Exception("Not found: '%s'" % relpath_re) Exception: Not found: 'python/cv2/py.typed' ---------------------------------------- ERROR: Failed building wheel for opencv-python Failed to build opencv-python ERROR: Could not build wheels for opencv-python, which is required to install pyproject.toml-based projects

请考虑我必须对上述命令进行一些修改,因为最后一个版本是 4 年后的版本,并且某些命令不起作用。即:

    libav-tools
  • 已替换为
    ffmpeg
    python-opengl
    已替换为
    PyOpenGL
    
    
  • sudo apt-get install ffmpeg sudo apt-get install python3-pip pip3 install PyOpenGL sudo apt-get install ffmpeg
我遵循了
stackoverflow线程

,但没有任何补救措施。

python opencv pip anaconda python-wheel
1个回答
0
投票
FlyingTeller

所评论的那样,我运行了 pip install --only-binary ":all:" opencv-python 并在 anaconda 环境中安装了

gym
。然后我得到以下日志:
Collecting gym==0.15.4
  Using cached gym-0.15.4-py3-none-any.whl
Requirement already satisfied: six in ./anaconda3/envs/universe/lib/python3.6/site-packages (from gym==0.15.4) (1.15.0)
Requirement already satisfied: scipy in ./anaconda3/envs/universe/lib/python3.6/site-packages (from gym==0.15.4) (1.5.0)
Collecting pyglet<=1.3.2,>=1.2.0
  Using cached pyglet-1.3.2-py2.py3-none-any.whl (1.0 MB)
Collecting cloudpickle~=1.2.0
  Using cached cloudpickle-1.2.2-py2.py3-none-any.whl (25 kB)
Requirement already satisfied: opencv-python in ./anaconda3/envs/universe/lib/python3.6/site-packages (from gym==0.15.4) (4.6.0.66)
Requirement already satisfied: numpy>=1.10.4 in ./anaconda3/envs/universe/lib/python3.6/site-packages (from gym==0.15.4) (1.18.5)
Requirement already satisfied: future in ./anaconda3/envs/universe/lib/python3.6/site-packages (from pyglet<=1.3.2,>=1.2.0->gym==0.15.4) (0.18.2)
Installing collected packages: pyglet, cloudpickle, gym
  Attempting uninstall: cloudpickle
    Found existing installation: cloudpickle 1.5.0
    Uninstalling cloudpickle-1.5.0:
      Successfully uninstalled cloudpickle-1.5.0
ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.
spyder 4.1.4 requires pyqt5<5.13; python_version >= "3", which is not installed.
spyder 4.1.4 requires pyqtwebengine<5.13; python_version >= "3", which is not installed.
distributed 2.20.0 requires cloudpickle>=1.3.0, but you have cloudpickle 1.2.2 which is incompatible.

根据我运行的不兼容性:
pip install pyqt5==5.12.3 pyqtwebengine==5.12.1

之后我运行

pip install gym==0.15.4
并且没有错误!
    

© www.soinside.com 2019 - 2024. All rights reserved.