numenta / htmresearch

Experimental algorithms. Unsupported.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ImportError: No module named research.connections with virtualenv

matejaputic opened this issue · comments

Under Ubuntu 16.04, to recreate:

git clone https://github.com/numenta/nupic.research.git
cd nupic.research
virtualenv -p /usr/bin/python2.7 nupic.research_venv
source nupic.research_venv/bin/activate
cd ../
git clone https://github.com/numenta/nupic.git
cd nupic
pip install -r requirements.txt
python setup.py install
cd ../nupic.research
pip install -r requirements.txt
python setup.py develop
cd htmresearch
python -c "from htmresearch.algorithms.extended_temporal_memory import ExtendedTemporalMemory"

produces

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/home/mp3t/Projects/nupic.research/htmresearch/algorithms/extended_temporal_memory.py", line 32, in <module>
    from nupic.research.connections import Connections, binSearch
ImportError: No module named research.connections

Hmm, is your nupic properly installed? Could you go to nupic and try: py.test tests/unit/?

It partially finishes

========= 2 failed, 574 passed, 18 skipped, 17 error in 25.72 seconds ==========

https://gist.github.com/014b4c22a42d3ccd8530f55aecdb2b44

I don't believe the errors in the nupic test are related to the error in the original post, are they?

No, but it's weird that you couldn't import something from nupic.

This is for a specific use case but if you ignore the nupic.vision-specific parts then this will get a complete nupic.research environment up (in Docker - Ubuntu 16.04): https://github.com/numenta/nupic.vision/blob/225c3ecde7cba90ef2d0b2463ec5bcbeca54380f/Dockerfile#L22-L61

@matejaputic nupic.research uses a different nupic.core C++ library called nupic.research.core.

To fix your environment you need to replace nupic.bindings package with nupic.research.core bindings package.

Here are the steps I used to fix, based on the environment you described above:

# uninstall original nupic.core bindings
pip uninstall nupic.bindings

# Optional, make sure cmake is installed
apt-get install cmake

# Clone and install nupic.research.core bindings
git clone https://github.com/numenta/nupic.research.core.git
cd nupic.research.core
pip install -r bindings/py/requirements.txt
pip install pycapnp==0.5.8
python setup.py install

# Test installation
cd ../nupic.research
cd htmresearch
python -c "from htmresearch.algorithms.extended_temporal_memory import ExtendedTemporalMemory"

Let me know if it works.

There's a writeup I did at https://github.com/numenta/nupic.research/wiki/nupic.core-feature-branch-workflow for configuring your remotes to accommodate the nupic.core-nupic.research.core setup.

The gist of it is, as @lscheinkman points out, use https://github.com/numenta/nupic.research.core in lieu of https://github.com/numenta/nupic.core for research code.

OK so I need nupic and bindings from nupic.research.core

Thank you, I did not know that. I guess what threw me off is that README.md says

Requirements: the main requirement is nupic.

so I just assumed that it was the trunk. If you can make it more specific in the README, I think that would fix this issue.

Thank you all kindly for your help!

Here's what happened to me when I tried lscheinkman's steps:

C02T81FFH03Q:nupic.research.core davebabbitt$ sudo -H pip2 install pycapnp --install-option '--force-bundled-libcapnp'
Password:
/usr/local/lib/python2.7/site-packages/pip/commands/install.py:194: UserWarning: Disabling all use of wheels due to the use of --build-options / --global-options / --install-options.
  cmdoptions.check_install_build_global(options)
Requirement already satisfied: pycapnp in /usr/local/lib/python2.7/site-packages/pycapnp-0.5.12-py2.7-macosx-10.12-x86_64.egg
C02T81FFH03Q:My Repositories davebabbitt$ cd nupic.research.core
C02T81FFH03Q:nupic.research.core davebabbitt$ /usr/local/opt/python/bin/python2.7 setup.py install
running install
running bdist_egg
running egg_info
creating src/htmresearch_core.egg-info
writing src/htmresearch_core.egg-info/PKG-INFO
writing top-level names to src/htmresearch_core.egg-info/top_level.txt
writing dependency_links to src/htmresearch_core.egg-info/dependency_links.txt
writing manifest file 'src/htmresearch_core.egg-info/SOURCES.txt'
reading manifest file 'src/htmresearch_core.egg-info/SOURCES.txt'
writing manifest file 'src/htmresearch_core.egg-info/SOURCES.txt'
installing library code to build/bdist.macosx-10.12-x86_64/egg
running install_lib
running build_py
creating build
creating build/lib.macosx-10.12-x86_64-2.7
creating build/lib.macosx-10.12-x86_64-2.7/htmresearch_core
copying src/htmresearch_core/__init__.py -> build/lib.macosx-10.12-x86_64-2.7/htmresearch_core
creating build/lib.macosx-10.12-x86_64-2.7/htmresearch_core/proto
copying src/htmresearch_core/proto/__init__.py -> build/lib.macosx-10.12-x86_64-2.7/htmresearch_core/proto
copying src/htmresearch_core/proto/ApicalTiebreakTemporalMemoryProto.capnp -> build/lib.macosx-10.12-x86_64-2.7/htmresearch_core/proto
running build_ext
building 'htmresearch_core.dummy' extension
creating build/temp.macosx-10.12-x86_64-2.7
clang -fno-strict-aliasing -fno-common -dynamic -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/usr/local/opt/openssl/include -I/usr/local/include -I/usr/local/opt/openssl/include -I/usr/local/opt/sqlite/include -I/usr/local/Cellar/python/2.7.14/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c dummy.c -o build/temp.macosx-10.12-x86_64-2.7/dummy.o
clang -bundle -undefined dynamic_lookup -L/usr/local/opt/openssl/lib -I/usr/local/opt/openssl/include build/temp.macosx-10.12-x86_64-2.7/dummy.o -L/usr/local/lib -L/usr/local/opt/openssl/lib -L/usr/local/opt/sqlite/lib -o build/lib.macosx-10.12-x86_64-2.7/htmresearch_core/dummy.so
creating build/bdist.macosx-10.12-x86_64
creating build/bdist.macosx-10.12-x86_64/egg
creating build/bdist.macosx-10.12-x86_64/egg/htmresearch_core
copying build/lib.macosx-10.12-x86_64-2.7/htmresearch_core/__init__.py -> build/bdist.macosx-10.12-x86_64/egg/htmresearch_core
copying build/lib.macosx-10.12-x86_64-2.7/htmresearch_core/dummy.so -> build/bdist.macosx-10.12-x86_64/egg/htmresearch_core
creating build/bdist.macosx-10.12-x86_64/egg/htmresearch_core/proto
copying build/lib.macosx-10.12-x86_64-2.7/htmresearch_core/proto/__init__.py -> build/bdist.macosx-10.12-x86_64/egg/htmresearch_core/proto
copying build/lib.macosx-10.12-x86_64-2.7/htmresearch_core/proto/ApicalTiebreakTemporalMemoryProto.capnp -> build/bdist.macosx-10.12-x86_64/egg/htmresearch_core/proto
byte-compiling build/bdist.macosx-10.12-x86_64/egg/htmresearch_core/__init__.py to __init__.pyc
byte-compiling build/bdist.macosx-10.12-x86_64/egg/htmresearch_core/proto/__init__.py to __init__.pyc
creating stub loader for htmresearch_core/dummy.so
byte-compiling build/bdist.macosx-10.12-x86_64/egg/htmresearch_core/dummy.py to dummy.pyc
creating build/bdist.macosx-10.12-x86_64/egg/EGG-INFO
copying src/htmresearch_core.egg-info/PKG-INFO -> build/bdist.macosx-10.12-x86_64/egg/EGG-INFO
copying src/htmresearch_core.egg-info/SOURCES.txt -> build/bdist.macosx-10.12-x86_64/egg/EGG-INFO
copying src/htmresearch_core.egg-info/dependency_links.txt -> build/bdist.macosx-10.12-x86_64/egg/EGG-INFO
copying src/htmresearch_core.egg-info/top_level.txt -> build/bdist.macosx-10.12-x86_64/egg/EGG-INFO
writing build/bdist.macosx-10.12-x86_64/egg/EGG-INFO/native_libs.txt
zip_safe flag not set; analyzing archive contents...
creating dist
creating 'dist/htmresearch_core-0.0.3.dev0-py2.7-macosx-10.12-x86_64.egg' and adding 'build/bdist.macosx-10.12-x86_64/egg' to it
removing 'build/bdist.macosx-10.12-x86_64/egg' (and everything under it)
Processing htmresearch_core-0.0.3.dev0-py2.7-macosx-10.12-x86_64.egg
Copying htmresearch_core-0.0.3.dev0-py2.7-macosx-10.12-x86_64.egg to /usr/local/lib/python2.7/site-packages
Adding htmresearch-core 0.0.3.dev0 to easy-install.pth file

Installed /usr/local/lib/python2.7/site-packages/htmresearch_core-0.0.3.dev0-py2.7-macosx-10.12-x86_64.egg
Processing dependencies for htmresearch-core==0.0.3.dev0
Finished processing dependencies for htmresearch-core==0.0.3.dev0
C02T81FFH03Q:nupic.research.core davebabbitt$ cd ../
C02T81FFH03Q:My Repositories davebabbitt$ git clone https://github.com/numenta/nupic.research.git
Cloning into 'nupic.research'...
remote: Counting objects: 30281, done.
remote: Compressing objects: 100% (12/12), done.
remote: Total 30281 (delta 8), reused 9 (delta 5), pack-reused 30264
Receiving objects: 100% (30281/30281), 377.61 MiB | 3.04 MiB/s, done.
Resolving deltas: 100% (20008/20008), done.
C02T81FFH03Q:My Repositories davebabbitt$ cd nupic.research
C02T81FFH03Q:nupic.research davebabbitt$ /usr/local/opt/python/bin/python2.7 -c "from nupic.research.spatial_pooler import SpatialPooler"
Traceback (most recent call last):
  File "<string>", line 1, in <module>
ImportError: No module named research.spatial_pooler
C02T81FFH03Q:nupic.research davebabbitt$