W10,使用命令提示符(不是Cygwin)。 Python 3.8.5。
我已经安装(使用pip)pytest并开始使用它,确定。我还使用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'
...有人知道可能是什么问题吗?
答案 0 :(得分:0)
此处是Python的低级用户。我所知道的是,我在W10中安装了Python虚拟环境,并使用相同的版本(3.8.5),然后安装(使用pip
,requests
,beautifulsoup4
和{{1} }。而且一切正常。