FerdousTheWebCoder
FerdousTheWebCoder

Reputation: 228

Keyerror when trying to testsuite pytest with pandas

Hi there all machine learning and python experts. I seek your help.

I have recently seen into google ml crash course. They recommended to get familiar with pandas before starting the crash course.

So, I have installed pip v8.1.1 using python v3.5.2 and pandas from pip. And also installed pytest 3.5.1 using pip.

But when I tried to use the recommended test suite given in the documentation of pandas installation page , I got errors.

user@host:~$ python3
Python 3.5.2 (default, Nov 23 2017, 16:37:01) 
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import pandas as pd
>>> pd.test()
running: pytest --skip-slow --skip-network /home/ashraf/.local/lib/python3.5/site-packages/pandas
==================================================================== test session starts ====================================================================
platform linux -- Python 3.5.2, pytest-3.5.1, py-1.5.3, pluggy-0.6.0
rootdir: /home/user, inifile:
collected 0 items / 1 errors                                                                                                                                

========================================================================== ERRORS ===========================================================================
_____________________________________________________________________ ERROR collecting  _____________________________________________________________________
.local/lib/python3.5/site-packages/_pytest/config.py:334: in _getconftestmodules
    return self._path2confmods[path]
E   KeyError: local('/home/user/.local/lib/python3.5/site-packages/pandas/tests/io')

During handling of the above exception, another exception occurred:
.local/lib/python3.5/site-packages/_pytest/config.py:365: in _importconftest
    return self._conftestpath2mod[conftestpath]
E   KeyError: local('/home/user/.local/lib/python3.5/site-packages/pandas/tests/io/conftest.py')

During handling of the above exception, another exception occurred:
.local/lib/python3.5/site-packages/_pytest/config.py:371: in _importconftest
    mod = conftestpath.pyimport()
.local/lib/python3.5/site-packages/py/_path/local.py:668: in pyimport
    __import__(modname)
.local/lib/python3.5/site-packages/_pytest/assertion/rewrite.py:213: in load_module
    py.builtin.exec_(co, mod.__dict__)
.local/lib/python3.5/site-packages/pandas/tests/io/conftest.py:3: in <module>
    import moto
E   ImportError: No module named 'moto'

During handling of the above exception, another exception occurred:
.local/lib/python3.5/site-packages/py/_path/common.py:377: in visit
    for x in Visitor(fil, rec, ignore, bf, sort).gen(self):
.local/lib/python3.5/site-packages/py/_path/common.py:429: in gen
    for p in self.gen(subdir):
.local/lib/python3.5/site-packages/py/_path/common.py:418: in gen
    dirs = self.optsort([p for p in entries
.local/lib/python3.5/site-packages/py/_path/common.py:419: in <listcomp>
    if p.check(dir=1) and (rec is None or rec(p))])
.local/lib/python3.5/site-packages/_pytest/main.py:434: in _recurse
    ihook = self.gethookproxy(path)
.local/lib/python3.5/site-packages/_pytest/main.py:338: in gethookproxy
    my_conftestmodules = pm._getconftestmodules(fspath)
.local/lib/python3.5/site-packages/_pytest/config.py:348: in _getconftestmodules
    mod = self._importconftest(conftestpath)
.local/lib/python3.5/site-packages/_pytest/config.py:376: in _importconftest
    raise ConftestImportFailure(conftestpath, sys.exc_info())
E   _pytest.config.ConftestImportFailure: ImportError("No module named 'moto'",)
E     File "/home/user/.local/lib/python3.5/site-packages/_pytest/assertion/rewrite.py", line 213, in load_module
E       py.builtin.exec_(co, mod.__dict__)
E     File "/home/user/.local/lib/python3.5/site-packages/pandas/tests/io/conftest.py", line 3, in <module>
E       import moto
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Interrupted: 1 errors during collection !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
================================================================== 1 error in 0.59 seconds ==================================================================

Now, how may I fix it, what may I be doing wrong or missing any package? Please, help me in it.

Upvotes: 1

Views: 1803

Answers (1)

phd
phd

Reputation: 94676

To run tests in pandas you need to install a lot of development requirements:

pip install -U [--user] ci/requirements_dev.txt

Upvotes: 1

Related Questions