# Nupic does not run unit tests

**URL:** <https://discourse.numenta.org/t/nupic-does-not-run-unit-tests/1798>\
**Category:** NuPIC\
**Created:** [January 17, 2017, 11:18am UTC](https://discourse.numenta.org/t/nupic-does-not-run-unit-tests/1798 "2017-01-17T11:18:14Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![nickmalhotra](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.numenta.org/nickmalhotra/32/1062_2.png) [@nickmalhotra](https://discourse.numenta.org/u/nickmalhotra)\
**Post date:** [January 17, 2017, 11:18am UTC](https://discourse.numenta.org/t/nupic-does-not-run-unit-tests/1798/1 "2017-01-17T11:18:14Z")

</div>

Current OS version : Ubuntu 16.04 LTS

OS type : 64 bit

Instructions followed on : [https://github.com/numenta/nupic](https://github.com/numenta/nupic)

Nupic version installed : 0.5.7  
nupic.bundings : 0.4.13

When I run the code it does not create an output and comes back with a random response.  
**from: can’t read /var/mail/subprocess**  
**from: can’t read /var/mail/optparse**  
**from: can’t read /var/mail/datetime**  
./scripts/run\_nupic\_tests.py: 27: Syntax error: “(” unexpected

Need to understand if I am doing anything wrong

---

<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:** [January 17, 2017, 4:24pm UTC](https://discourse.numenta.org/t/nupic-does-not-run-unit-tests/1798/2 "2017-01-17T16:24:15Z")

</div>

I don’t have any confidence on Ubuntu 16 just yet, [we have not made a concerted attempt to build on it](https://discourse.numenta.org/t/nupic-on-ubuntu-16-04-lts/563). YMMV with new versions of Ubuntu.

---

<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:** [January 17, 2017, 5:03pm UTC](https://discourse.numenta.org/t/nupic-does-not-run-unit-tests/1798/3 "2017-01-17T17:03:09Z")

</div>

The error from [https://github.com/numenta/nupic/blob/master/scripts/run\_nupic\_tests.py#L27](https://github.com/numenta/nupic/blob/master/scripts/run_nupic_tests.py#L27) looks like you might have a different version of python? NuPIC requires 2.6+

---

<div class="post-metadata">

**Author:** ![digame](https://avatars.discourse-cdn.com/v4/letter/d/a4c791/32.png) [@digame](https://discourse.numenta.org/u/digame)\
**Post date:** [February 17, 2018, 2:06am UTC](https://discourse.numenta.org/t/nupic-does-not-run-unit-tests/1798/4 "2018-02-17T02:06:45Z")

</div>

I’ve run into the exact same issue. Any progress? I’m running Python 2.7.12.

john@john-XPS-13-9343:~/numenta/nupic$ ./scripts/run\_nupic\_tests.py -w  
from: can’t read /var/mail/subprocess  
from: can’t read /var/mail/optparse  
from: can’t read /var/mail/datetime  
./scripts/run\_nupic\_tests.py: line 27: syntax error near unexpected token `(' ./scripts/run_nupic_tests.py: line 27:`from pkg\_resources import (’

---

<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:** [February 17, 2018, 6:31am UTC](https://discourse.numenta.org/t/nupic-does-not-run-unit-tests/1798/5 "2018-02-17T06:31:46Z")

</div>

You may think you are running python 2.7, but I bet you are not. What OS are you using? And do you have multiple versions of python installed? That is usually the problem.

---

<div class="post-metadata">

**Author:** ![digame](https://avatars.discourse-cdn.com/v4/letter/d/a4c791/32.png) [@digame](https://discourse.numenta.org/u/digame)\
**Post date:** [February 17, 2018, 8:34am UTC](https://discourse.numenta.org/t/nupic-does-not-run-unit-tests/1798/6 "2018-02-17T08:34:40Z")

</div>

Hi Matt,

Thanks for the quick reply! I

confess I’m a newbie to NuPIC. I’ve watched about 9 of your videos  
(nice! btw) and decided to start playing with code to explore more.

My background: DOS C/C++/ASM (no really, I’m that old.) Windows  
C/C++/.NET, Linux: C/C++ Ruby, etc. Weak on Python, but when reading it,  
it reads like code… LOTs of projects involving interfacing/controlling  
HW devices incl. motion control, video processing spectral analysis.

To your questions:

OS:

/$ lsb\_release -a  
No LSB modules are available.  
Distributor ID: Ubuntu  
Description: Ubuntu 16.04.3 LTS  
Release: 16.04  
Codename: xenial

Python versions installed:

$ ls -ls /usr/bin/python\*  
0 lrwxrwxrwx 1 root root 9 Jun 5 2016 /usr/bin/python -\>  
python2.7  
0 lrwxrwxrwx 1 root root 9 Jun 5 2016 /usr/bin/python2 -\>  
python2.7  
3412 -rwxr-xr-x 1 root root 3492656 Dec 4 10:14 /usr/bin/python2.7  
0 lrwxrwxrwx 1 root root 33 Dec 4 10:14  
/usr/bin/python2.7-config -\> x86\_64-linux-gnu-python2.7-config  
0 lrwxrwxrwx 1 root root 16 Dec 9 2015  
/usr/bin/python2-config -\> python2.7-config  
0 lrwxrwxrwx 1 root root 9 Jun 5 2016 /usr/bin/python3 -\>  
python3.5  
4360 -rwxr-xr-x 2 root root 4464400 Nov 28 08:53 /usr/bin/python3.5  
4360 -rwxr-xr-x 2 root root 4464400 Nov 28 08:53 /usr/bin/python3.5m  
0 lrwxrwxrwx 1 root root 10 Jun 5 2016 /usr/bin/python3m -\>  
python3.5m  
0 lrwxrwxrwx 1 root root 16 Dec 9 2015 /usr/bin/python-config  
-\> python2.7-config

Default Python?:

$ which python  
/usr/bin/python

(…looks like they symlink points to 2.7)

Python version details:

$ python --version  
Python 2.7.12

Could the python 3.5 install be causing problems?

Thanks again,

John

![](https://canada1.discourse-cdn.com/flex030/uploads/numenta/original/2X/e/e276c9a82d8d2f9d116ae48e9ac8acbdd4ce8d33.png)

---

<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:** [February 17, 2018, 4:08pm UTC](https://discourse.numenta.org/t/nupic-does-not-run-unit-tests/1798/7 "2018-02-17T16:08:19Z")

</div>

How did you install nupic? If you used pip, also find out what version of pip you used.

---

<div class="post-metadata">

**Author:** ![digame](https://avatars.discourse-cdn.com/v4/letter/d/a4c791/32.png) [@digame](https://discourse.numenta.org/u/digame)\
**Post date:** [February 18, 2018, 3:06am UTC](https://discourse.numenta.org/t/nupic-does-not-run-unit-tests/1798/8 "2018-02-18T03:06:41Z")

</div>

Hmm…

$ pip --version  
pip 8.1.1 from /usr/lib/python2.7/dist-packages (python 2.7)

I installed from source using the instructions found here: [https://github.com/numenta/nupic](https://github.com/numenta/nupic)

_Installing NuPIC From Source_  
_To install from local source code, run from the repository root:_  
_pip install ._

…but, now that I read the instructions again, I see that you want pip \>=8.1.2 (I’m one rev back.) I’ll upgrade and try again.

Thanks!

---

<div class="post-metadata">

**Author:** ![digame](https://avatars.discourse-cdn.com/v4/letter/d/a4c791/32.png) [@digame](https://discourse.numenta.org/u/digame)\
**Post date:** [February 18, 2018, 4:36am UTC](https://discourse.numenta.org/t/nupic-does-not-run-unit-tests/1798/9 "2018-02-18T04:36:13Z")

</div>

**Well, upgraded pip, grabbed a fresh repository and tried to install again from source.**

**PIP**

_~/numenta/nupic$ pip --version_  
_pip 9.0.1 from /usr/local/lib/python2.7/dist-packages (python 2.7)_

**Fresh Install…**

_~/numenta/nupic$ pip install . --user_  
_Processing /home/john/numenta/nupic_  
_Requirement already satisfied: asteval==0.9.1 in /usr/local/lib/python2.7/dist-packages (from nupic==1.0.4.dev0)_  
_Requirement already satisfied: coverage==3.7.1 in /usr/local/lib/python2.7/dist-packages (from nupic==1.0.4.dev0)_  
…  
\_ Running setup.py install for nupic … done\_  
_ **Successfully installed nupic-1.0.4.dev0 nupic.bindings-1.0.3** _  
\_

**Unit tests still have issues…**

_~/numenta/nupic$ py.test tests/unit_  
_============ test session starts ================================_  
_platform linux2 – Python 2.7.12, pytest-3.0.7, py-1.5.2, pluggy-0.4.0_  
_rootdir: /home/john/numenta/nupic, inifile:_  
_plugins: xdist-1.16.0, cov-2.5.0_  
\_collected 735 items \_

_tests/unit/nupic/serializable\_test.py …_  
_tests/unit/nupic/utils\_test.py …_  
_tests/unit/nupic/algorithms/anomaly\_likelihood\_jeff\_test.py …ss…_  
_tests/unit/nupic/algorithms/anomaly\_likelihood\_test.py …_  
_tests/unit/nupic/algorithms/anomaly\_test.py …_  
_tests/unit/nupic/algorithms/backtracking\_tm\_constant\_test.py …_  
_tests/unit/nupic/algorithms/backtracking\_tm\_cpp2\_test.py ._  
_tests/unit/nupic/algorithms/backtracking\_tm\_cpp\_test.py …_  
_tests/unit/nupic/algorithms/backtracking\_tm\_test.py …_

**…**  
**Issues with the examples?**  
**…**

_tests/unit/nupic/data/generators/sequence\_machine\_test.py …_  
_ **tests/unit/nupic/docs/examples\_test.py .xx.xxxxxx** _  
_tests/unit/nupic/encoders/adaptivescalar\_test.py …_

**…**

_tests/unit/nupic/support/consoleprinter\_test/consoleprinter\_test.py ._

_=========== pytest-warning summary ==============================_  
_WC1 /home/john/numenta/nupic/tests/unit/nupic/engine/network\_test.py cannot collect test class ‘TestNode’ because it has a **init** constructor_  
_WC1 /home/john/numenta/nupic/tests/unit/nupic/frameworks/opf/htmpredictionmodel\_classifier\_helper\_test.py cannot collect test class ‘TestOptionParser’ because it has a **init** constructor_  
_WC1 /home/john/numenta/nupic/tests/unit/nupic/regions/knn\_anomaly\_classifier\_region\_test.py cannot collect test class ‘TestOptionParser’ because it has a **init** constructor_  
_WC1 /home/john/numenta/nupic/tests/unit/nupic/support/decorators\_test.py cannot collect test class ‘TestParentException’ because it has a **init** constructor_  
_WC1 /home/john/numenta/nupic/tests/unit/nupic/support/decorators\_test.py cannot collect test class ‘TestChildException’ because it has a **init** constructor_  
_=======710 passed, 17 skipped, **8 xfailed** , 5 pytest-warnings in 113.87 seconds=================_

**Thoughts?**

---

<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:** [February 18, 2018, 7:25am UTC](https://discourse.numenta.org/t/nupic-does-not-run-unit-tests/1798/10 "2018-02-18T07:25:23Z")

</div>

Try running tests with this script

> <https://github.com/numenta/nupic/blob/master/scripts/run_nupic_tests.py>

---

<div class="post-metadata">

**Author:** ![flarelink](https://avatars.discourse-cdn.com/v4/letter/f/9fc29f/32.png) [@flarelink](https://discourse.numenta.org/u/flarelink)\
**Post date:** [September 2, 2018, 8:13pm UTC](https://discourse.numenta.org/t/nupic-does-not-run-unit-tests/1798/11 "2018-09-02T20:13:53Z")

</div>

Hello,

I’m new to the forums and HTM so I’m trying to run these unit tests but I’m getting the same errors as @nickmalhotra above.

> [@nickmalhotra](#):
>
> When I run the code it does not create an output and comes back with a random response.  
> **from: can’t read /var/mail/subprocess**  
> **from: can’t read /var/mail/optparse**  
> **from: can’t read /var/mail/datetime**  
> ./scripts/run\_nupic\_tests.py: 27: Syntax error: “(” unexpected

**OS:** Ubuntu 18.04.1 LTS 64-bit.  
**pip version:** pip 9.0.1 from /usr/lib/python2.7/dist-packages (python 2.7)  
**python version:** Python 2.7.15rc1  
**setuptools version:** 39.0.1-2  
**wheel version:** 0.30.0-0.2  
**numpy version:** 1.12.1  
**gcc version:** 4:7.3.0-3ubuntu2

When I run $ pip freeze | grep nupic I get the following output:  
nupic==1.0.5  
nupic.bindings==1.0.6

Is there something wrong with my nupic install?

Thank you for your time and have a nice day.

---

<div class="post-metadata">

**Author:** ![Jose\_Cueto](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.numenta.org/jose_cueto/32/4052_2.png) [@Jose\_Cueto](https://discourse.numenta.org/u/Jose_Cueto)\
**Post date:** [September 3, 2018, 9:52am UTC](https://discourse.numenta.org/t/nupic-does-not-run-unit-tests/1798/12 "2018-09-03T09:52:18Z")

</div>

Try running `python scripts/run_nupic_tests.py`, instead of calling the script directly. Looks like there is an issue in your python env.

---

<div class="post-metadata">

**Author:** ![flarelink](https://avatars.discourse-cdn.com/v4/letter/f/9fc29f/32.png) [@flarelink](https://discourse.numenta.org/u/flarelink)\
**Post date:** [September 3, 2018, 6:52pm UTC](https://discourse.numenta.org/t/nupic-does-not-run-unit-tests/1798/13 "2018-09-03T18:52:31Z")

</div>

When I run `python scripts/run_nupic_tests.py` I receive this output:

$ python scripts/run\_nupic\_tests.py  
Traceback (most recent call last):  
File “scripts/run\_nupic\_tests.py”, line 262, in   
os.chdir(os.getenv(‘NUPIC’))  
TypeError: coercing to Unicode: need string or buffer, NoneType found

Looking into it on the forum, it was recommended uninstalling nupic completely and reinstalling it with the --user flag and this didn’t fix it. The bindings are on 1.0.6, but does having nupic on 1.0.5 cause any sort of problems?

I have both python 2 and python 3 installed but I confirmed that by running $python that a python 2 shell opens. So I’m not sure if it’s an issue in my python env.

---

<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:** [September 3, 2018, 8:29pm UTC](https://discourse.numenta.org/t/nupic-does-not-run-unit-tests/1798/14 "2018-09-03T20:29:44Z")

</div>

> [@flarelink](#):
>
> does having nupic on 1.0.5 cause any sort of problems?

Yes it does. Uninstall completely and reinstall.

> [@Uninstalling NuPIC](https://discourse.numenta.org/t/uninstalling-nupic/2175):
>
> Run the following commands: pip uninstall nupic -y pip uninstall nupic.bindings. -y Run these commands until you see console output similar to this for each command: Cannot uninstall requirement nupic, not installed You can also do this by running explicitly rming the nupic.bindings-\* files from your site-packages directory.

---

<div class="post-metadata">

**Author:** ![Jose\_Cueto](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.numenta.org/jose_cueto/32/4052_2.png) [@Jose\_Cueto](https://discourse.numenta.org/u/Jose_Cueto)\
**Post date:** [September 3, 2018, 10:17pm UTC](https://discourse.numenta.org/t/nupic-does-not-run-unit-tests/1798/15 "2018-09-03T22:17:29Z")

</div>

You are almost there. This is how I ran the unit tests. Assuming you are in an OSX or Linux machine by the way.

```auto
NUPIC=<path-to-nupic> python scripts/run_nupic_tests.py

```

That error means the NUPIC environment variable wasn’t set, so you have to set it first. This is pretty much standard way to run a python unit test suite.

---

<div class="post-metadata">

**Author:** ![flarelink](https://avatars.discourse-cdn.com/v4/letter/f/9fc29f/32.png) [@flarelink](https://discourse.numenta.org/u/flarelink)\
**Post date:** [September 5, 2018, 2:46am UTC](https://discourse.numenta.org/t/nupic-does-not-run-unit-tests/1798/16 "2018-09-05T02:46:39Z")

</div>

Sorry for all the trouble. I uninstalled nupic completely and when I run $ pip freeze | grep nupic I still receive:  
nupic==1.0.5  
nupic.bindings==1.0.6

Looking at the installation on [https://github.com/numenta/nupic](https://github.com/numenta/nupic) I ran the command $ pip install .

That was able to update my nupic so now when I run $ pip freeze | grep nupic I receive the output:  
nupic==1.0.6.dev0  
nupic.bindings==1.0.6

Thankfully I’m now on 1.0.6 for both so my next step was setting the NUPIC environment variable. I ran the following commands to do so/check this.

flarelink@flarelink:~/nupic  
 pwd /home/flarelink/nupic flarelink@flarelink:~/nupic NUPIC=`pwd`  
flarelink@flarelink:~/nupic  
$ echo $NUPIC  
/home/flarelink/nupic

However, after running $ python scripts/run\_nupic\_tests.py I still receive the same output.

$ python scripts/run\_nupic\_tests.py  
Traceback (most recent call last):  
File “scripts/run\_nupic\_tests.py”, line 262, in  
os.chdir(os.getenv(‘NUPIC’))  
TypeError: coercing to Unicode: need string or buffer, NoneType found

Am I misunderstanding how to set the environment variable here? I’m not too familiar with python and its package management.

---

<div class="post-metadata">

**Author:** ![flarelink](https://avatars.discourse-cdn.com/v4/letter/f/9fc29f/32.png) [@flarelink](https://discourse.numenta.org/u/flarelink)\
**Post date:** [September 5, 2018, 2:48am UTC](https://discourse.numenta.org/t/nupic-does-not-run-unit-tests/1798/17 "2018-09-05T02:48:05Z")

</div>

I’m still a little new to Python but can you look at my reply to @rhyolight and see if I’m still doing something wrong?

---

<div class="post-metadata">

**Author:** ![Jose\_Cueto](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.numenta.org/jose_cueto/32/4052_2.png) [@Jose\_Cueto](https://discourse.numenta.org/u/Jose_Cueto)\
**Post date:** [September 5, 2018, 3:23am UTC](https://discourse.numenta.org/t/nupic-does-not-run-unit-tests/1798/18 "2018-09-05T03:23:30Z")

</div>

`flarelink@flarelink:~/nupic NUPIC=pwd`

Here you have set NUPIC as an uninheritable environment variable, thus it is still not visible to the test runner script. See the error.

You must do either one of the following;

```auto
1. NUPIC=`pwd` python scripts/run_nupic_tests.py
2. NUPIC=<absolute path to nupic> python scripts/run_nupic_tests.py
3. export NUPIC=<absolute path to nupic>
   python scripts/run_nupic_tests.py

```

---

<div class="post-metadata">

**Author:** ![flarelink](https://avatars.discourse-cdn.com/v4/letter/f/9fc29f/32.png) [@flarelink](https://discourse.numenta.org/u/flarelink)\
**Post date:** [September 5, 2018, 3:39am UTC](https://discourse.numenta.org/t/nupic-does-not-run-unit-tests/1798/19 "2018-09-05T03:39:21Z")

</div>

It ran! 😃 Thank you so much! I used your first command:

> [@Jose\_Cueto](#):
>
> 1. NUPIC=`pwd` python scripts/run\_nupic\_tests.py

All the tests are supposed to pass though right? The end summary has some skips, xfails, and warnings:

========================================================================================== pytest-warning summary ==========================================================================================  
WC1 /home/flarelink/nupic/tests/unit/nupic/engine/network\_test.py cannot collect test class ‘TestNode’ because it has a **init** constructor  
WC1 /home/flarelink/nupic/tests/unit/nupic/frameworks/opf/htmpredictionmodel\_classifier\_helper\_test.py cannot collect test class ‘TestOptionParser’ because it has a **init** constructor  
WC1 /home/flarelink/nupic/tests/unit/nupic/regions/knn\_anomaly\_classifier\_region\_test.py cannot collect test class ‘TestOptionParser’ because it has a **init** constructor  
WC1 /home/flarelink/nupic/tests/unit/nupic/support/decorators\_test.py cannot collect test class ‘TestParentException’ because it has a **init** constructor  
WC1 /home/flarelink/nupic/tests/unit/nupic/support/decorators\_test.py cannot collect test class ‘TestChildException’ because it has a **init** constructor  
================================================================== 715 passed, 17 skipped, 8 xfailed, 5 pytest-warnings in 221.30 seconds ==================================================================

I ran the same command with the -u flag like so: $ NUPIC=`pwd` python scripts/run\_nupic\_tests.py -u

Where I still end up with skip, xfails, and warnings:

========================================================================================== pytest-warning summary ==========================================================================================  
WC1 /home/flarelink/nupic/tests/unit/nupic/engine/network\_test.py cannot collect test class ‘TestNode’ because it has a **init** constructor  
WC1 /home/flarelink/nupic/tests/unit/nupic/frameworks/opf/htmpredictionmodel\_classifier\_helper\_test.py cannot collect test class ‘TestOptionParser’ because it has a **init** constructor  
WC1 /home/flarelink/nupic/tests/unit/nupic/regions/knn\_anomaly\_classifier\_region\_test.py cannot collect test class ‘TestOptionParser’ because it has a **init** constructor  
WC1 /home/flarelink/nupic/tests/unit/nupic/support/decorators\_test.py cannot collect test class ‘TestParentException’ because it has a **init** constructor  
WC1 /home/flarelink/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 207.14 seconds ==================================================================

---

<div class="post-metadata">

**Author:** ![Jose\_Cueto](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.numenta.org/jose_cueto/32/4052_2.png) [@Jose\_Cueto](https://discourse.numenta.org/u/Jose_Cueto)\
**Post date:** [September 5, 2018, 3:46am UTC](https://discourse.numenta.org/t/nupic-does-not-run-unit-tests/1798/20 "2018-09-05T03:46:33Z")

</div>

Hooray. Please note that you have to use the backticks “``” for the `pwd` to be executed first.

Please rerun the command with the backticks.

[Next page](https://discourse.numenta.org/t/nupic-does-not-run-unit-tests/1798.md?page=2)
