简体   繁体   中英

virtualenv doesnt find installed module when running tests [Pytest]

I'm writing my first test for a class where I imported an external packages ( installed via pip in the venv ). I'm using PyCharm as an IDE and it the package in question is listed there under the project interpreter ( the venv ) as well as when I type pip freeze in console. Now I want to run a run-tests.sh file and when my test is reached pytest is returning me an ERROR : E ImportError: No module named 'magic'

The code line which fails the test is obviously the import statement in my class which I want to test.

Any ideas?

//Edit: for clarification: NOT the terminal itself is throwing the Error! PYTEST does!

make sure that you have installed packages through pycharm, if it don't list your package, it means that you install your package in other place, go to file > setting > project:[NAME] >interpreter to check it. then yo can use "+" to install package

fixed it myself. for some dubious reason pytest and my venv did have a problem. reinstalled pytest within my virtual env via pip install pytest

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