Pytest "Error: could not load path/to/conftest.py" : <p>I get the following error when I try to run <code>pytest repo/tests/test_file.py</code>:</p>

<pre><code>$ pytest repo/tests/test_file.py
Traceback (most recent call last):
  File "/Users/marlo/anaconda3/envs/venv/lib/python3.6/site-packages/_pytest/config.py", line 329, in _getconftestmodules
    return self._path2confmods[path]
KeyError: local('/Users/marlo/repo/tests/test_file.py')

During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "/Users/marlo/anaconda3/envs/venv/lib/python3.6/site-packages/_pytest/config.py", line 329, in _getconftestmodules
    return self._path2confmods[path]
KeyError: local('/Users/marlo/repo/tests')

During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "/Users/marlo/anaconda3/envs/venv/lib/python3.6/site-packages/_pytest/config.py", line 362, in _importconftest
    return self._conftestpath2mod[conftestpath]
KeyError: local('/Users/marlo/repo/conftest.py')

During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "/Users/marlo/anaconda3/envs/venv/lib/python3.6/site-packages/_pytest/config.py", line 368, in _importconftest
    mod = conftestpath.pyimport()
  File "/Users/marlo/anaconda3/envs/venv/lib/python3.6/site-packages/py/_path/local.py", line 686, in pyimport
    raise self.ImportMismatchError(modname, modfile, self)
py._path.local.LocalPath.ImportMismatchError: ('conftest', '/home/venvuser/venv/conftest.py', local('/Users/marlo/repo/conftest.py'))
ERROR: could not load /Users/marlo/repo/conftest.py
</code></pre>

<p>My repo structure is</p>

<pre><code>lib/
    -tests/
        -test_file.py
app/
    -test_settings.py
pytest.ini
conftest.py
...
</code></pre>

<p>Other people have run this code fine, and according to <a href="https://stackoverflow.com/questions/33964355/how-to-i-organize-my-pytest-tests-if-im-not-distributing-them-with-my-package">this question</a> (and <a href="https://stackoverflow.com/questions/18558666/how-do-i-get-py-test-to-recognize-conftest-py-in-a-subdirectory">this one</a>), my structure is good and I am not missing any files.  I can only conclude that something about my computer or project set-up is not right.  If you have any suggestions or insights that I may be missing, please send them my way!</p>

<p>-------------------------------MORE DETAILS------------------------------</p>

<p><strong>test_file.py</strong>:</p>

<pre><code>def func(x):
    return x + 1

def test_answer():
    assert func(3) == 5
</code></pre>

<p><strong>pytest.ini</strong>:</p>

<pre><code>[pytest]
DJANGO_SETTINGS_MODULE = app.test_settings
python_files = tests.py test_* *_tests.py *test.py
</code></pre>
