为什么pytest看不到beautifulsoup模块?

2024-10-08 20:16:10 发布

您现在位置:Python中文网/ 问答频道 /正文

W10,使用命令提示符(不是Cygwin)。Python 3.8.5

我已经安装(使用pip)pytest并开始使用它OK。我还使用pip安装了BeautifulSoup4,并开始使用它OK(在非测试文件中)

但是,当我尝试使用pytest运行一个包含行import bs4的文件时,它会抱怨:

_

ImportError while importing test module 'D:\more software projects\Visual_Studio\caat-testing\caat-test1\url_test\test_caat_url.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
d:\apps\python\python36\lib\importlib\__init__.py:126: in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
test_caat_url.py:56: in <module>
    from bs4 import BeautifulSoup
E   ModuleNotFoundError: No module named 'bs4'

。。。有人知道问题出在哪里吗


Tags: pip文件inpytestimporturlpytest
1条回答
网友
1楼 · 发布于 2024-10-08 20:16:10

这里是一个低级Python用户。我只知道我在W10中安装了一个Python虚拟环境,并使用相同的版本(3.8.5),然后安装(使用piprequestsbeautifulsoup4pytest。一切正常

相关问题 更多 >

    热门问题