第三方库:pandas;如果在终端直接执行 pytest,会报错:

____________________ ERROR collecting tests/test.py _____________________
ImportError while importing test module ''.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/importlib/__init__.py:127: in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
tests/test.py:17: in <module>
    from utils import check, logger, excel_analyzer
utils/excel.py:4: in <module>
    import pandas as pd
E   ModuleNotFoundError: No module named 'pandas'

但是直接在 python 命令行导入,没问题:

请问是因为 pytest 无法在 sh 中使用的原因吗?如何解决这个问题?


↙↙↙阅读原文可查看相关链接,并与作者交流