Skip to content

Instantly share code, notes, and snippets.

@birkin
Last active April 21, 2020 12:34
Show Gist options
  • Select an option

  • Save birkin/3b17a11ccbfa512a59565296ce4c7ff4 to your computer and use it in GitHub Desktop.

Select an option

Save birkin/3b17a11ccbfa512a59565296ce4c7ff4 to your computer and use it in GitHub Desktop.
hddm install notes

hddm install notes

Issue

Some python package installs these days suggest starting with Anaconda for understandable good reasons.

I'm a software developer working primarily in python, and want to experiment with Anaconda, and learn, in particular, how to best use it with virtual-environments.

However, in the meantime, I like to be able to experiment with packages using my normal dev-architecture:

  • create a 'stuff directory'
  • create an 'env' directory (the virtual environment)
  • activate the virtual environment
  • pip install packages into the virtual environment

Here are some notes about installing hddm on my mac...

Note that there were some errors I didn't capture, and though I briefly successfully re-installed the package to produce these notes, I may not have uninstalled some things so-as to get a clean environment.

Steps

Basic initial steps...

$ mkdir ./hddm_stuff

$ cd ./hddm_stuff/

$ python3 -m venv ./env_hddm

$ ls
total 0
drwxr-xr-x    3 birkin  staff    96B Nov 25 19:49 ./
drwxr-xr-x+ 169 birkin  staff   5.3K Nov 25 19:48 ../
drwxr-xr-x    6 birkin  staff   192B Nov 25 19:49 env_hddm/
$

$ source ./env_hddm/bin/activate
(env_hddm) $

Update pip...

(env_hddm) $ pip install pip --upgrade
[output snipped]
Successfully installed pip-18.1
(env_hddm) $

Non-basic steps...

  • install numpy

    • The normal next step does not work; that step would be: $ pip install git+https://github.com/hddm-devs/hddm.git

    • But that yields an error: ModuleNotFoundError: No module named 'numpy'

    • So we'll install that:

        (env_hddm) $ pip install numpy
        [output snipped]
        Successfully installed numpy-1.15.4
      
  • install gfortran compiler

    • "fortran, you say? Are you sure?" I know, I know; I hadn't heard of that in a while.

    • Unfortunately I didn't capture the exact error, but some step of the main pip-install command assumes the existence, as I recall, of a fortran compiler on your computer. Googling around led me to try installing gfortran via homebrew.

    • Homebrew is a great package-manager for the mac -- basically, if you need a unix-package for the mac that's not part of the default mac darwin-unix environment, homebrew is a great way to get it installed. The details of using homebrew are beyond the scope of these install notes, but, in summary, after homebrew is installed, I like to run brew update to make sure I have the latest default homebrew setup -- and then run and rerun brew doctor, following any suggested instructions to make sure I have the 'cleanest' environment possible. Then I install the target package.

        (env_hddm) $ brew update
        [potentially lots of output]
      
        (env_hddm) $ brew doctor
        Your system is ready to brew.
      
    • Ok, we're ready

        (env_hddm) $ brew install gfortran
        Error: No available formula with the name "gfortran"
        GNU Fortran is now provided as part of GCC, and can be installed with:
          brew install gcc
      
    • Ok, I'll follow this suggestion

        (env_hddm) $ brew install gcc
        [lots of output snipped]
      
  • install Cython

    • The normal main pip-install step now yields the error: clang: error: no such file or directory: 'src/wfpt.c'

    • Googling around, I found a suggestion to pip-install Cython. I like to give credit for suggestions that work, but I didn't save the reference. And I haven't even bothered to grok what Cython is :/ -- but onward...

        (env_hddm) $ pip install Cython
      
  • set environment variable #1

    • The normal main pip-install step now yields a different error. Again, I didn't properly capture it -- I think some step of compilation couldn't find some part of the numpy library -- but googling led me to try (use your full path to your env directory):

        (env_hddm) $ export CFLAGS="-I /path/to/env_hddm/lib/python3.6/site-packages/numpy/core/include $CFLAGS"
      
  • set environment variable #2

    • The normal main pip-install step yields a different error than the one above. Yet again, I didn't properly capture it -- I think some step of the compilation couldn't find an openssl library. Googling, a website suggested something to try, which WORKED:

        (env_hddm) $ env LDFLAGS="-L$(brew --prefix openssl)/lib" CFLAGS="-I$(brew --prefix openssl)/include" pip install git+https://github.com/hddm-devs/hddm.git
        [some output snipped]
        Successfully installed HDDM-0.6.1
      

Woohoo! (Whew)


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment