You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

GitHub Actions执行pytest时遭遇ModuleNotFoundError: No module named 'pybind11_tests'问题求助

GitHub Actions执行pytest时遭遇ModuleNotFoundError: No module named 'pybind11_tests'问题求助

大家好,我最近在配置GitHub Actions的Python CI工作流时碰到了一个棘手的问题,想请教下社区的朋友们。

我搭建了一个针对Python项目的CI工作流,在成功完成libbdsg的编译后,运行pytest测试时却出现了pybind11_tests模块找不到的错误。我初步排查后怀疑,问题可能是libbdsg的构建过程修改了pybind11的Python模块路径,或者是bdsg的Python绑定没有被正确链接、安装到Python可以识别的位置。

下面是我使用的工作流yml脚本:

name: Python CI

on:
  push:
    branches:
      - main
  pull_request:
    branches:
      - main

jobs:
  test:
    runs-on: ubuntu-latest

    steps:
    - name: Checkout the repository
      uses: actions/checkout@v3

    - name: Set up Python
      uses: actions/setup-python@v4
      with:
        python-version: '3.10'

    - name: Install requirements dependencies
      run: |
        pip install cyvcf2==0.31.1
        pip install numpy==2.0.1
        pip install pandas==2.2.2
        pip install statsmodels==0.14.4
        pip install qmplot==0.3.3
        pip install scipy==1.14.1
        pip install setuptools==75.6.0
        pip install scikit-learn==1.6.0
        pip install matplotlib==3.9.4
        pip install seaborn==0.13.2
        pip install plotly==5.24.1
        pip install pytest==8.3.4

    - name: Install pybind11
      run: |
        pip3 install --no-cache-dir pybind11

    - name: Install libbdsg
      run: |
        sudo apt-get update
        sudo apt-get install -y --no-install-recommends libjansson-dev doxygen
        git clone --recursive https://github.com/vgteam/libbdsg.git
        cd libbdsg
        mkdir build
        cd build
        cmake ..
        make -j 8
        pip3 install --no-cache-dir bdsg

    - name: Run pytest tests
      run: python3 -m pytest

执行时出现的错误信息如下:

# Run python3 -m pytest
#   python3 -m pytest
#   shell: /usr/bin/bash -e {0}
#   env:
#     pythonLocation: /opt/hostedtoolcache/Python/3.10.15/x64
#     PKG_CONFIG_PATH: /opt/hostedtoolcache/Python/3.10.15/x64/lib/pkgconfig
#     Python_ROOT_DIR: /opt/hostedtoolcache/Python/3.10.15/x64
#     Python2_ROOT_DIR: /opt/hostedtoolcache/Python/3.10.15/x64
#     Python3_ROOT_DIR: /opt/hostedtoolcache/Python/3.10.15/x64
#     LD_LIBRARY_PATH: /opt/hostedtoolcache/Python/3.10.15/x64/lib
# Traceback (most recent call last):
#   File "/home/runner/work/STOAT/STOAT/libbdsg/bdsg/deps/pybind11/tests/conftest.py", line 20, in <module>
#     import pybind11_tests
# ModuleNotFoundError: No module named 'pybind11_tests'
# Unable to find the test binary "/opt/hostedtoolcache/Python/3.10.15/x64/lib/python3.10/site-packages/pytest/gtest_catch_exceptions_ex_test_". Please make sure to provide
# a path to the binary via the --build_dir flag or the BUILD_DIR

有没有朋友遇到过类似的问题?或者能给我一些排查的方向和解决建议?

备注:内容来源于stack exchange,提问作者Plogeur

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.14 13:00:28