Skip to content
This repository has been archived by the owner on Aug 16, 2023. It is now read-only.

Homebrew butterflow 0.1.9 package import error #10

Closed
dthpham opened this issue Jun 28, 2015 · 1 comment
Closed

Homebrew butterflow 0.1.9 package import error #10

dthpham opened this issue Jun 28, 2015 · 1 comment

Comments

@dthpham
Copy link
Owner

dthpham commented Jun 28, 2015

Looks like a problem with PYTHONPATH not including $(brew --prefix)/lib/python2.7/site-packages.

~ > brew install butterflow
==> Installing butterflow from homebrew/homebrew-science
==> Downloading https://homebrew.bintray.com/bottles-science/butterflow-0.1.9.yo
Already downloaded: /Library/Caches/Homebrew/butterflow-0.1.9.yosemite.bottle.tar.gz
==> Pouring butterflow-0.1.9.yosemite.bottle.tar.gz
🍺  /usr/local/Cellar/butterflow/0.1.9: 21 files, 192K
~ > butterflow -h
Traceback (most recent call last):
  File "/usr/local/Cellar/butterflow/0.1.9/libexec/bin/butterflow", line 9, in <module>
    load_entry_point('butterflow==0.1.9', 'console_scripts', 'butterflow')()
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources.py", line 357, in load_entry_point
    return get_distribution(dist).load_entry_point(group, name)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources.py", line 2394, in load_entry_point
    return ep.load()
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources.py", line 2108, in load
    entry = __import__(self.module_name, globals(),globals(), ['__name__'])
  File "/usr/local/Cellar/butterflow/0.1.9/libexec/lib/python2.7/site-packages/butterflow/cli.py", line 6, in <module>
    from cv2 import calcOpticalFlowFarneback as sw_farneback_optical_flow
ImportError: No module named cv2
~ > locate cv2.so
/usr/local/Cellar/opencv/2.4.11/lib/python2.7/site-packages/cv2.so
/usr/local/lib/python2.7/site-packages/cv2.so
~ > cat `brew --prefix`/Cellar/butterflow/0.1.9/bin/butterflow
#!/bin/bash
PYTHONPATH="/usr/local/Cellar/butterflow/0.1.9/libexec/lib/python2.7/site-packages" exec "/usr/local/Cellar/butterflow/0.1.9/libexec/bin/butterflow" "$@"
dthpham added a commit that referenced this issue Jun 29, 2015
@dthpham
Copy link
Owner Author

dthpham commented Jun 29, 2015

After a quick investigation...

The cv2.so module is guaranteed to be available when dependencies are installed and it is correctly placed in $(brew --prefix)/python2.7/site-packages, which is the standard location for Homebrew formulas with Python bindings to be installed in. However, the problem lies in the fact that the executable that sets PYTHONPATH before launching butterflow doesn't include this directory:

$ cat $(brew --prefix)/Cellar/butterflow/0.1.9/bin/butterflow
#!/bin/bash
PYTHONPATH="/usr/local/Cellar/butterflow/0.1.9/libexec/lib/python2.7/site-packages" exec "/usr/local/Cellar/butterflow/0.1.9/libexec/bin/butterflow" "$@"

The fix is to simply prepend the site-packages path to PYTHONPATH inside the butterflow.rb formula:

ENV.prepend_create_path "PYTHONPATH", "#{HOMEBREW_PREFIX}/lib/python2.7/site-packages"

A pull request to fix the package will be submitted soon.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant