简体   繁体   中英

Why can't pytest see beautifulsoup module?

W10, using the Command Prompt (not Cygwin). Python 3.8.5.

I've installed (using pip) pytest and have started using it OK. I've also installed BeautifulSoup4 using pip and started using it OK (in a non-test file).

But when I try to run a file with pytest which includes the line import bs4 it complains:

_

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'

... anyone know what the problem might be?

A low-level Python user here. All I know is that I installed a Python virtual environment in W10 and using the same version (3.8.5) then installed (using pip ), requests , beautifulsoup4 and pytest . And everything just works.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM