0

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.

any suggestions what else could be wrong/missing?

4
  • 1
    Could be because of the python path issue have you tried python -m pytest projectrootdir/ Commented Dec 14, 2017 at 4:38
  • This worked. Thanks @NareshKumar Commented Dec 14, 2017 at 4:44
  • what does the -m stand for? I have issues with pylint as well...unable to import memoize (import-error) Commented Dec 29, 2017 at 4:24
  • you can check python --help for more details on arguments. The issue is with the path variables you might be having different version python/modules and your root project folder is not in the sys.path for python to process it correctly. Commented Dec 29, 2017 at 6:58

1 Answer 1

2

The python path could be the issue

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

Sign up to request clarification or add additional context in comments.

2 Comments

The above command helped pytest work. but linter raises this Unable to import 'memoize' (import-error) any idea how to avoid this. I tried uninstalling the global version, and installing memoize again. didn't help
Could you provide your project tree structure? You can also check the following doc PYTHONPATH . To check your current path Finding-current-path-used

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.