首页 > 编程问答 >GitHub Actions 工作流程中的 moviepy 安装错误:subprocess-exited-with-error

GitHub Actions 工作流程中的 moviepy 安装错误:subprocess-exited-with-error

时间:2024-08-01 06:29:04浏览次数:13  
标签:python flask frontend backend

我尝试在 GitHub Actions 工作流程中安装 moviepy 时遇到错误。在我的本地机器上安装工作正常,但在 CI 环境中有时会失败。该错误消息表明获取构建轮子的要求未成功运行,退出代码为 1。它还提到该错误源自子进程,并且可能不是 pip 的问题。

Downloading moviepy-1.0.3.tar.gz (388 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 388.3/388.3 kB 32.9 MB/s eta 0:00:00
  Installing build dependencies: started
  Installing build dependencies: finished with status 'done'
  Getting requirements to build wheel: started
  Getting requirements to build wheel: finished with status 'error'
  error: subprocess-exited-with-error
  
  × Getting requirements to build wheel did not run successfully.
  │ exit code: 1
  ╰─> [20 lines of output]
      Traceback (most recent call last):
        File "/opt/hostedtoolcache/Python/3.11.9/x64/lib/python3.11/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 353, in <module>
          main()
        File "/opt/hostedtoolcache/Python/3.11.9/x64/lib/python3.11/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 335, in main
          json_out['return_val'] = hook(**hook_input['kwargs'])
                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/opt/hostedtoolcache/Python/3.11.9/x64/lib/python3.11/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 118, in get_requires_for_build_wheel
          return hook(config_settings)
                 ^^^^^^^^^^^^^^^^^^^^^
        File "/tmp/pip-build-env-dismlhz9/overlay/lib/python3.11/site-packages/setuptools/build_meta.py", line 327, in get_requires_for_build_wheel
          return self._get_build_requires(config_settings, requirements=[])
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/tmp/pip-build-env-dismlhz9/overlay/lib/python3.11/site-packages/setuptools/build_meta.py", line 297, in _get_build_requires
          self.run_setup()
        File "/tmp/pip-build-env-dismlhz9/overlay/lib/python3.11/site-packages/setuptools/build_meta.py", line 497, in run_setup
          super().run_setup(setup_script=setup_script)
        File "/tmp/pip-build-env-dismlhz9/overlay/lib/python3.11/site-packages/setuptools/build_meta.py", line 313, in run_setup
          exec(code, locals())
        File "<string>", line 21, in <module>
      NameError: name 'TestCommand' is not defined
      [end of output]
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
error: subprocess-exited-with-error

× Getting requirements to build wheel did not run successfully.
│ exit code: 1
╰─> See above for output.

note: This error originates from a subprocess, and is likely not a problem with pip.

Notice:  A new release of pip is available: 24.1.2 -> 24.2
Notice:  To update, run: pip install --upgrade pip

我的 github 操作文件|| |我已经尝试升级 pip 和 setuptools,但问题仍然存在。以下是我的 GitHub Actions 工作流程文件的相关部分:


name: Build and deploy Python app to Azure Web App - speaksmart-ai

on:
  push:
    branches:
      - main
  workflow_dispatch:

jobs:
  build:
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v4

      - name: Set up Python version
        uses: actions/setup-python@v5
        with:
          python-version: '3.11'

      - name: Create and start virtual environment
        run: |
          python -m venv venv
          source venv/bin/activate
      
      - name: Install dependencies
        run: pip install -r requirements.txt
        
      # Optional: Add step to run tests here (PyTest, Django test suites, etc.)

      - name: Zip artifact for deployment
        run: zip release.zip ./* -r

      - name: Upload artifact for deployment jobs
        uses: actions/upload-artifact@v4
        with:
          name: python-app
          path: |
            release.zip
            !venv/

........

将 Python 版本设置为 3.11。 创建并启动虚拟环境。 从requirements.txt 安装依赖项。

Setting up Python version to 3.11. Creating and starting a virtual environment. Installing dependencies from requirements.txt.


此错误信息表明 moviepy 包在构建 wheel 文件时遇到了问题,具体原因是构建过程中执行的某个子进程返回了错误代码 1。错误信息指向了 NameError: name 'TestCommand' is not defined ,这表示在 setuptools 的构建过程中缺少了 TestCommand 类。

以下是几种可能的解决方案:

1. 更新 setuptools:

TestCommand 类在 setuptools 较新版本中可能有所更改。尝试升级 setuptools 到最新版本:

bash pip install --upgrade setuptools

2. 指定 moviepy 版本:

特定版本的 moviepy 可能会与的 setuptools 版本不兼容。尝试指定一个已知可用的 moviepy 版本:

bash pip install moviepy==1.0.2 # 或其他可用的版本

3. 使用 wheel 文件安装:

直接安装预构建的 wheel 文件可以避免构建过程中的问题。首先,找到与的 Python 版本和操作系统架构匹配的 moviepy wheel 文件 ( https://pypi.org/project/moviepy/#files )。 然后,下载 wheel 文件并使用 pip 安装:

bash pip install moviepy-1.0.3-py3-none-any.whl # 将文件名替换为实际下载的文件名

4. 检查其他依赖项:

moviepy 依赖于其他库,例如 numpy、imageio 等。确保这些依赖项也已正确安装并且版本兼容。

5. 调试构建过程:

如果以上方法均无效,可以尝试在本地环境中模拟 GitHub Actions 环境并调试构建过程。这可以通过创建虚拟环境并使用与 GitHub Actions 相同的操作系统和 Python 版本进行操作。

修改后的 GitHub Actions 工作流程:

在的 GitHub Actions 工作流程中,可以将上述解决方案应用到依赖项安装步骤中。例如,使用以下代码更新的步骤:

- name: Install dependencies
  run: |
    python -m pip install --upgrade pip setuptools wheel
    pip install -r requirements.txt

这将确保 pip、setuptools 和 wheel 包在安装其他依赖项之前已更新到最新版本。还可以尝试在 requirements.txt 文件中指定 moviepy 的特定版本。

希望这些解决方案能够帮助解决 moviepy 安装错误问题!

标签:python,flask,frontend,backend
From: 78806467

相关文章