Nupic does not run unit tests

Current OS version : Ubuntu 16.04 LTS

OS type : 64 bit

Instructions followed on : 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

1 Like

I don’t have any confidence on Ubuntu 16 just yet, we have not made a concerted attempt to build on it. YMMV with new versions of Ubuntu.

The error from 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+

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 (’

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.

2 Likes

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

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

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

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!

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?

1 Like

Try running tests with this script

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.

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.

1 Like

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

1 Like

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.

1 Like

Yes it does. Uninstall completely and reinstall.

1 Like

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

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.

1 Like

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 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.

1 Like

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?

1 Like

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;

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
1 Like

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

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 ==================================================================

1 Like

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

Please rerun the command with the backticks.

1 Like