# Nupic Unit Test Failing

**URL:** <https://discourse.numenta.org/t/nupic-unit-test-failing/6449>\
**Category:** NuPIC\
**Created:** [August 11, 2019, 7:52pm UTC](https://discourse.numenta.org/t/nupic-unit-test-failing/6449 "2019-08-11T19:52:50Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Suraj](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.numenta.org/suraj/32/4218_2.png) [@Suraj](https://discourse.numenta.org/u/Suraj)\
**Post date:** [August 11, 2019, 7:52pm UTC](https://discourse.numenta.org/t/nupic-unit-test-failing/6449/1 "2019-08-11T19:52:50Z")

</div>

Hi. I’ve recently installed Nupic using “pip install nupic --user”, and I cloned the github repo. But when I run the unit tests, I get failures. Any suggestions?  
My specs:  
macOS 10.12  
pip 19.1.1  
python 2.7  
python 3.5 _**(which is why I specify python2 in the command below)**_

My console looks like:

```
Katherines-MBP:nupic kateellis1$ python2 -m py.test tests/unit

**=================================================== test session starts ====================================================**
platform darwin -- Python 2.7.16, pytest-3.0.7, py-1.8.0, pluggy-0.4.0
rootdir: /Users/kateellis1/Desktop/Suraj/HTM/nupic, inifile:
plugins: xdist-1.16.0, cov-2.5.0
**collected 738 items** 

tests/unit/nupic/serializable_test.py ...
tests/unit/nupic/utils_test.py ......
tests/unit/nupic/algorithms/anomaly_likelihood_jeff_test.py ...ss..
***Skipping a bunch of similar lines***
tests/unit/nupic/support/group_by_test.py ......
tests/unit/nupic/support/object_json_test.py ...............
tests/unit/nupic/support/consoleprinter_test/consoleprinter_test.py .

================================================== pytest-warning summary ==================================================
WC1 /Users/kateellis1/Desktop/Suraj/HTM/nupic/tests/unit/nupic/engine/network_test.py cannot collect test class 'TestNode' because it has a __init__ constructor
***Skipping a bunch of similar lines***
WC1 /Users/kateellis1/Desktop/Suraj/HTM/nupic/tests/unit/nupic/support/decorators_test.py cannot collect test class 'TestChildException' because it has a __init__ constructor
**========================== 713 passed, 17 skipped, 8 xfailed, 5 pytest-warnings in 265.82 seconds ==========================**

```

I also tried the following:

`Katherines-MBP:nupic kateellis1$ python2 -m scripts/run_nupic_tests.py tests/unit`

And I got the output:  
`/usr/local/opt/python@2/bin/python2.7: Import by filename is not supported.`

Thanks for any help.

---

<div class="post-metadata">

**Author:** ![rhyolight](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.numenta.org/rhyolight/32/3922_2.png) [@rhyolight](https://discourse.numenta.org/u/rhyolight)\
**Post date:** [August 12, 2019, 8:26pm UTC](https://discourse.numenta.org/t/nupic-unit-test-failing/6449/2 "2019-08-12T20:26:49Z")

</div>

> [@Suraj](#):
>
> Hi. I’ve recently installed Nupic using “pip install nupic --user”, and I cloned the github repo. But when I run the unit tests, I get failures. Any suggestions?

Hi @Suraj. Try this from the root repo directory:

```
python ./scripts/run_nupic_tests.py -u --failfast

```

---

<div class="post-metadata">

**Author:** ![Suraj](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.numenta.org/suraj/32/4218_2.png) [@Suraj](https://discourse.numenta.org/u/Suraj)\
**Post date:** [August 12, 2019, 9:34pm UTC](https://discourse.numenta.org/t/nupic-unit-test-failing/6449/3 "2019-08-12T21:34:03Z")

</div>

Hi @rhyolight,  
When I ran your command, the test session said that it was running `Python 3.5.6`, which is odd since `python -V` gives me `Python 2.7.16`. So I tried specifying python2, as in `python2 ./scripts/run_nupic_tests.py -u --failfast`, and again it said it was running `Python 3.5.6`, which I don’t understand. So finally I created a new conda environment for Python 2.7. This time, when I ran your command, it worked and spit out hundreds of lines of test results, but it still says ` **==== 713 passed, 17 skipped, 8 xfailed, 5 pytest-warnings in 534.95 seconds ====** `

Here are some of the skips and xfails:

`tests/unit/nupic/docs/examples_test.py::ExamplesTest::testFiveStepConfidencesOpfVsNetwork <- ../../../../anaconda/envs/python2env/lib/python2.7/site-packages/unittest2/case.py xfail`

`tests/unit/nupic/docs/examples_test.py::ExamplesTest::testFiveStepPredictionsOpfVsNetwork <- ../../../../anaconda/envs/python2env/lib/python2.7/site-packages/unittest2/case.py xfail`

`tests/unit/nupic/algorithms/anomaly_likelihood_jeff_test.py::ArtificialAnomalyTest::testCaseMissingBunchesOfSpikes <- ../../../../anaconda/envs/python2env/lib/python2.7/site-packages/unittest2/case.py SKIPPED`

`tests/unit/nupic/algorithms/anomaly_likelihood_jeff_test.py::ArtificialAnomalyTest::testCaseMissingSpike <- ../../../../anaconda/envs/python2env/lib/python2.7/site-packages/unittest2/case.py SKIPPED`

---

<div class="post-metadata">

**Author:** ![rhyolight](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.numenta.org/rhyolight/32/3922_2.png) [@rhyolight](https://discourse.numenta.org/u/rhyolight)\
**Post date:** [August 12, 2019, 11:00pm UTC](https://discourse.numenta.org/t/nupic-unit-test-failing/6449/4 "2019-08-12T23:00:05Z")

</div>

Ok, I replicated this on conda and got the same test results. Then I realized you were citing `xfail`, which is “expected failure”. So nothing wrong here. 😛

---

<div class="post-metadata">

**Author:** ![Suraj](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.numenta.org/suraj/32/4218_2.png) [@Suraj](https://discourse.numenta.org/u/Suraj)\
**Post date:** [August 12, 2019, 11:25pm UTC](https://discourse.numenta.org/t/nupic-unit-test-failing/6449/5 "2019-08-12T23:25:02Z")

</div>

Oh good! Thanks for looking into that!

What is the ideal method for avoiding Python version problems when using NUPIC? Is virtualenv preferable over conda?

Also, regarding my previous errors (before I created the new environment), do you have any idea why the tests were invoking Python 3 even though I was using Python 2 on the command line?

Thanks again.

---

<div class="post-metadata">

**Author:** ![rhyolight](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.numenta.org/rhyolight/32/3922_2.png) [@rhyolight](https://discourse.numenta.org/u/rhyolight)\
**Post date:** [August 13, 2019, 1:14am UTC](https://discourse.numenta.org/t/nupic-unit-test-failing/6449/6 "2019-08-13T01:14:34Z")

</div>

> [@Suraj](#):
>
> Is virtualenv preferable over conda?

I’ve used both, and it’s just a personal preference.

> [@Suraj](#):
>
> do you have any idea why the tests were invoking Python 3 even though I was using Python 2 on the command line?

Running python 2 & 3 can be a bit tricky depending on your OS. The Mac python environment is particularly hairy. It probably had something to do with python 3 being invoked as the default python from within the test runner.
