简体   繁体   English

ModuleNotFoundError:没有名为“记忆”的模块

[英]ModuleNotFoundError: No module named 'memoize'

I tried this, 我试过了

pip install memoize
Requirement already satisfied: memoize

But every time i run pytest, I get the above error ModuleNotFoundError: No module named 'memoize' and it fails to load the conftest.py file even though it is in my tests folder and it also contains an __init__.py file. 但是每次运行pytest时,都会出现上述错误ModuleNotFoundError: No module named 'memoize'即使它位于我的测试文件夹中并且也包含__init__.py文件,它也无法加载conftest.py文件。

any suggestions what else could be wrong/missing? 还有什么建议可能是错误的/遗漏的吗?

The python path could be the issue python路径可能是问题

python -m pytest projectroot / python -m pytest projectroot /

To fix this you could also set the path using 要解决此问题,您还可以使用

import sys, os
myPath = os.path.dirname(os.path.abspath(__file__)) 
sys.path.insert(0, myPath + '/../')

By @Not_a_golfer 由@Not_a_golfer

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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