Not sure if this is more google-cloud-related or pytest-related. See files below.
When I run either python app/my_script.py
or python -m app.my_script
, the script runs fine.
But when I run pytest
, the line in the script from google.cloud import vision
throws "ModuleNotFoundError: No module named 'google.cloud'".
I have tried unsuccessfully to add various package names into the requirements.txt file and/or run pip install google-cloud
and pip install google-cloud-language
with and without --upgrade
flags. What steps can I take to overcome this error?
conftest.py: (empty)
requirements.txt:
google-cloud-vision
app/my_script.py:
from google.cloud import vision
from google.cloud.vision import types
def new_client():
client = vision.ImageAnnotatorClient()
return client
if __name__ == "__main__":
client = new_client()
# etc...
test/test_my_script.py:
from app.my_script import new_client
# tests here...