can't import fn_temp_dir when running pytest mcmodels
ChristianNitzsche opened this issue · 7 comments
Hi,
I tried to install the package, which seemed fine in the first place. But when trying 'pytest mcmodels' i get the following error:
____________________________ ERROR collecting mcmodels/core/tests/test_voxel_model_api.py _____________________________
ImportError while importing test module 'C:\Users\Christian\Desktop\Projekte\mouse_connectivity_models\mcmodels\core\tests\test_voxel_model_api.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
mcmodels\core\tests\test_voxel_model_api.py:9: in
from allensdk.test_utilities.temp_dir import fn_temp_dir
E ImportError: cannot import name 'fn_temp_dir' from 'allensdk.test_utilities.temp_dir' (C:\Users\Christian\Anaconda3\lib\site-packages\allensdk\test_utilities\temp_dir.py)
___________________________ ERROR collecting mcmodels/core/tests/test_voxel_model_cache.py ____________________________
ImportError while importing test module 'C:\Users\Christian\Desktop\Projekte\mouse_connectivity_models\mcmodels\core\tests\test_voxel_model_cache.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
mcmodels\core\tests\test_voxel_model_cache.py:11: in
from allensdk.test_utilities.temp_dir import fn_temp_dir
E ImportError: cannot import name 'fn_temp_dir' from 'allensdk.test_utilities.temp_dir' (C:\Users\Christian\Anaconda3\lib\site-packages\allensdk\test_utilities\temp_dir.py)
I am using:
Python 3.7.4
allensdk==0.16.3
mouse-connectivity-models==0.0.1
Is it possible, that the method fn_temp_dir was renamed into temp_dir in allensdk.test_utilities.temp_dir?
Thanks for your time
Christian
I just tried pytest, and it's working for me (on Linux). It's possible you may have a problem with your python configuration. I'd suggest working with an Anaconda environment specific for this. If you have access to a Linux machine, that would also be a good thing to try.
Perhaps the output of pytest that I ran can be helpful:
(py36) [kameron@fiddlehead mouse_connectivity_models]$ pytest mcmodels
============================= test session starts ==============================
platform linux -- Python 3.6.8, pytest-4.3.1, py-1.8.0, pluggy-0.9.0
rootdir: /home/kameron/src/mouse_connectivity_models, inifile:
plugins: remotedata-0.3.1, openfiles-0.3.2, doctestplus-0.3.0, arraydiff-0.3
collected 109 items
mcmodels/core/tests/test_base.py ..... [ 4%]
mcmodels/core/tests/test_experiment.py ....... [ 11%]
mcmodels/core/tests/test_masks.py .......... [ 20%]
mcmodels/core/tests/test_utils.py .. [ 22%]
mcmodels/core/tests/test_voxel_model_api.py ........ [ 29%]
mcmodels/core/tests/test_voxel_model_cache.py ........... [ 39%]
mcmodels/models/homogeneous/tests/test_homogeneous_model.py ... [ 42%]
mcmodels/models/homogeneous/tests/test_subset_selection.py ... [ 44%]
mcmodels/models/voxel/tests/test_regionalized_model.py ....... [ 51%]
mcmodels/models/voxel/tests/test_voxel_connectivity_array.py ........... [ 61%]
...... [ 66%]
mcmodels/models/voxel/tests/test_voxel_model.py .... [ 70%]
mcmodels/regressors/nonnegative_linear/tests/test_base.py .... [ 74%]
mcmodels/regressors/nonnegative_linear/tests/test_ridge.py ... [ 77%]
mcmodels/regressors/nonparametric/tests/test_kernels.py ....... [ 83%]
mcmodels/regressors/nonparametric/tests/test_nadaraya_watson.py ........ [ 90%]
.... [ 94%]
mcmodels/tests/test_utils.py ...... [100%]
========================== 109 passed in 5.65 seconds ==========================
(py36) [kameron@fiddlehead mouse_connectivity_models]$
Hey,
I am having the identical issue as Christian, both on Windows and Linux, inside a conda virtual environment.
$ pytest mcmodels
============================================================================== test session starts ===============================================================================
platform linux -- Python 3.7.4, pytest-5.2.1, py-1.8.0, pluggy-0.13.0
rootdir: /home/nomi/Documents/mouse_connectivity_models
collected 90 items / 2 errors / 88 selected
===================================================================================== ERRORS =====================================================================================
__________________________________________________________ ERROR collecting mcmodels/core/tests/test_voxel_model_api.py __________________________________________________________
ImportError while importing test module '/home/nomi/Documents/mouse_connectivity_models/mcmodels/core/tests/test_voxel_model_api.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
mcmodels/core/tests/test_voxel_model_api.py:9: in <module>
from allensdk.test_utilities.temp_dir import fn_temp_dir
E ImportError: cannot import name 'fn_temp_dir' from 'allensdk.test_utilities.temp_dir' (/home/nomi/.linuxbrew/opt/python/lib/python3.7/site-packages/allensdk/test_utilities/temp_dir.py)
_________________________________________________________ ERROR collecting mcmodels/core/tests/test_voxel_model_cache.py _________________________________________________________
ImportError while importing test module '/home/nomi/Documents/mouse_connectivity_models/mcmodels/core/tests/test_voxel_model_cache.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
mcmodels/core/tests/test_voxel_model_cache.py:11: in <module>
from allensdk.test_utilities.temp_dir import fn_temp_dir
E ImportError: cannot import name 'fn_temp_dir' from 'allensdk.test_utilities.temp_dir' (/home/nomi/.linuxbrew/opt/python/lib/python3.7/site-packages/allensdk/test_utilities/temp_dir.py)
================================================================================ warnings summary ================================================================================
/home/nomi/.linuxbrew/opt/python/lib/python3.7/site-packages/jinja2/utils.py:485
/home/nomi/.linuxbrew/opt/python/lib/python3.7/site-packages/jinja2/utils.py:485: DeprecationWarning: Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated, and in 3.8 it will stop working
from collections import MutableMapping
/home/nomi/.linuxbrew/opt/python/lib/python3.7/site-packages/jinja2/runtime.py:318
/home/nomi/.linuxbrew/opt/python/lib/python3.7/site-packages/jinja2/runtime.py:318: DeprecationWarning: Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated, and in 3.8 it will stop working
from collections import Mapping
-- Docs: https://docs.pytest.org/en/latest/warnings.html
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Interrupted: 2 errors during collection !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
========================================================================== 2 warnings, 2 error in 2.10s ==========================================================================
(allenenv) nomi@bio-h4tmkb2:~/Documents/mouse_connectivity_models$ ls
```
@ChristianNitzsche Hey, I had the same error and I think I found the source of the error. Try changing the files
/mcmodels/mouse_connectivity_models/mcmodels/core/tests/test_voxel_model_api.py
/mcmodels/mouse_connectivity_models/mcmodels/core/tests/test_voxel_model_cache.py
to the ones that I have attached here. I think the developers possibly have a different version of allenSDK and there are broken dependencies in the publicly available version.
Thanks @nbingo ... if you think the tests need to be updated, please submit a pull request and we can try integrating your fixes.
Thank you @nbingo and @kharris! @ChristianNitzsche, @justuskebschull I'm going to leave this issue open for a few days in case the error is not corrected for you. Please let us know if the issue is not resolved.
I started from a fresh clone of this module on python 3.7, newest version of allensdk, and it passes the tests.