Nupic Installation on MacOS(12.0) error

Welcome to the world of software development (on a Mac)!

Let me point out that development on a Mac is very challenging. This has recently become more acute with the release of Monterey (OSX 12) because I believe a prime directive at Apple is security and the protections in place with 12 are severe. Does this mean you cannot develop with a Mac? No, of course not, but you need to be aware that at every turn the OS is going to question why you want access to a file and why you want to write one and where. I am simplifying this for the purpose of discussion, but the main takeaway is have patience.

You may also want to invest in Parallels. It emulates Windows 11 excellently and not only allows you to run everything developed for Windows, but it also provides something of a protected sandbox environment.

Yeah, I guess in this case, though, it is just a question of how to get all the dependencies I need installed, so that I can even build it properly. I have no idea at the moment how to get make on the system. I guess maybe I have to use something else now like brew to build it. How crazy.

Got a little further, but it seems like a neverending cascade of errors

[ 4%] Building CXX object src/CMakeFiles/LibrarySource.dir/htm/encoders/DateEncoder.cpp.o
[ 5%] Building CXX object src/CMakeFiles/LibrarySource.dir/htm/encoders/ScalarEncoder.cpp.o
1 error generated.
make[2]: *** [src/CMakeFiles/LibrarySource.dir/htm/algorithms/TemporalMemory.cpp.o] Error 1
make[2]: *** Waiting for unfinished jobs…
make[1]: *** [src/CMakeFiles/LibrarySource.dir/all] Error 2
make: *** [all] Error 2
Traceback (most recent call last):
File “setup.py”, line 412, in
getExtensionFiles(platform, build_type)
File “setup.py”, line 239, in getExtensionFiles
generateExtensions(platform, build_type)
File “setup.py”, line 303, in generateExtensions
subprocess.check_call([“cmake”, “–build”, “.”, “–target”, “install”, “–config”, build_type, “–”, “-j”, “4”])
File “/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/subprocess.py”, line 364, in check_call
raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command ‘[‘cmake’, ‘–build’, ‘.’, ‘–target’, ‘install’, ‘–config’, ‘Release’, ‘–’, ‘-j’, ‘4’]’ returned non-zero exit status 2.

The following just worked for me (OSX 12.3) yesterday afternoon because some of the dependencies were updated. This is a modification of @sheiser1 's list from earlier in the thread. If you have already cloned the git repo, delete that clone and clone it again.

  • clone htm.core: git clone https://github.com/htm-community/htm.core.git
  • cd to htm.core dir: cd htm.core
  • create a new conda environment: conda create -n htm_env python=3.9.7
  • activate the the new environment: conda activate htm_env
  • install requirements pip install -r requirements.txt
  • modify cmake file CommonCompilerConfig.cmake: see below
  • run python setup: python setup.py install

The cmake file to modify is CommonCompilerConfig.cmake on line 282 you’ll find this line:

set (internal_compiler_warning_flags ${internal_compiler_warning_flags} -Werror -Wextra -Wreturn-type -Wunused -Wno-unused-variable -Wno-unused-parameter -Wno-missing-field-initializers)

The flag -Werror appears to convert warnings into errors. Remove that flag, changing that line to:

set (internal_compiler_warning_flags ${internal_compiler_warning_flags} -Wextra -Wreturn-type -Wunused -Wno-unused-variable -Wno-unused-parameter -Wno-missing-field-initializers)

Here is the latest entry on git log for my version of htm.core, if you see this entry in your git log, your version is at least as up to date as mine and will, hopefully, compile:

commit e04b993a699d2fdb3437f0506c101f779e13c59f (HEAD -> master, origin/master, origin/HEAD)
Merge: 8f83e926e d0113b37d
Author: David Keeney <dkeeney@users.noreply.github.com>
Date:   Tue Apr 5 11:00:58 2022 -0700

    Merge pull request #977 from htm-community/remove-unused-imports
    
    Remove unused import statements in setup.py
2 Likes

Oh, I forgot about homebrew, glad you mentioned it. It seems that in ‘the big picture’ the cognoscenti recommend that brew be used under Monterey. Brew will handle all the dependencies automatically, but there are a few pkgs (MacText comes to mind) that brew falls apart on. I go brew first and then to separate pkg installs as needed.

Yeah, been trying to use it, but a lot of stuff still isn’t working right.
Not really sure what I am doing wrong.
Might have to start over again.
Would be nice to get this working, so an explicit set of steps can be provided, so people aren’t struggling to even get it to compile and work properly.

I call that the ‘tragic cascade’, like in King Lear. When I was an undergrad I worked for the Computer Center (think ‘Mainframe’) and sat at a theatre ticket window and helped other students with their programming questions. It was exclusively other engineers as we had no CS department. Anyway, and it was invariably a civil engineer trying to run a sewage system piping simulation, I would say “Take that comma out and rerun it.” Then they would be incredulous, because the number of errors were extensive. Then I had to explain that because of that one comma, FORTRAN was not declaring the variable and all through the program, each time that variable or a subsequent calc was accessed, the compiler threw an error. The ‘tragic cascade’ :wink:

We just made some changes (updated the third part software versions) in htm.core that ‘might’ help. Start with a new clone and rebuild. You will probably need Brew.
We no longer have a Mac machine to use for regression tests so input from Mac users is particularly valuable to us.

So if you still have problems with htm.core or have updates for our docs, please create a new issue at: Issues · htm-community/htm.core · GitHub and we will attempt to address it.

Let me try to build it again now.

I just tried the new clone. It builds successfully and passes all tests on Monterey 12.3.1, using Anaconda Python 3.9 and Xcode13.2.
However, the build fails with Xcode13.3. This failure is not new and is the reason for my keeping Xcode 13.2 on my system.

1 Like

Can you provide the steps you used to build it?
How did you get Xcode 13.2?

I may not remember all the steps to set up my environment since it has evolved over time. But basically:

  1. Install Anaconda.
  2. Install boost with conda
  3. Install any of the Python requirements with conda if they are in the conda repository. If not use pip. I think that hexy was the only one in the latter category.
  4. You can download older Xcode versions form Apple Developer in the “Additional downloads” section. You will need an Apple Id to access that. BTW maintaining multiple Xcode versions is a pain. If you want to know how to do it, just Google it.
  5. Follow the build instructions in the htm.core Read.me. If it complains of any missing packages look for them first in the conda repository (you may need to use conda-forge versions) and if that fails try pip.

I hope that this helps.

If the change posted by @finnoshea is used, then the build with Xcode 13.3.1 succeeds and passes all unit tests.

I am using the procedure described by TheFinn, and when I try
$python setup.py install
I get messages
Traceback (most recent call last):
File “/Users/hal/htm.core/setup.py”, line 32, in
from packaging import version
ModuleNotFoundError: No module named ‘packaging’

My solution was to add prior to line 32:

sys.path.insert(0, “/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages”)

This solved the problem, although there may be a way more appropriate to Anaconda.

I also had to use pip3 instead of pip to get all the required modules.

1 Like