update Homebrew, install vtk, ImportError, link vtk to import vtk, install mayavi, installing Scrapy, on Mac OSX Yosemite

Update Homebrew

Keep your Homebrew updated. cf. Keeping Your Homebrew Up to Date

brew update

Install vtk with Homebrew

brew install vtk

If you want to install vtk with qt, then you add, append “flags” (those — things):

brew install vtk --qt

Note: I didn’t do this, I only installed vtk.

It took me about 27 minutes for brew to build vtk on a 2.4 GHz Intel Core i5, 57 minutes on a ~1.7 GHz MacBook Air (mid-2011).

Then I get ImportError when trying to import vtk in Python

cf. installing Mayavi with pip – no module named vtk
problem installing Mayavi with pip – no module named vtk

brew puts vtk here:

/usr/local/Cellar/vtk/6.2.0
(you can find out with brew info vtk)

and brew links vtk here:

/usr/local/lib/python2.7/site-packages/vtk

So I find that import vtk in Python doesn’t find vtk as it does the PYTHONPATH look up. You can check by doing in Python


import sys
print(sys.path)

brew info vtk has the answer: cf. Where can I find the installed package path via brew


Python modules have been installed and Homebrew's site-packages is not
in your Python sys.path, so you will not be able to import the modules
this formula installed. If you plan to develop with these modules,
please run:
mkdir -p /Users/ernestyeung/Library/Python/2.7/lib/python/site-packages
echo 'import site; site.addsitedir("/usr/local/lib/python2.7/site-packages")' >> /Users/ernestyeung/Library/Python/2.7/lib/python/site-packages/homebrew.pth

where ernestyeung would be your user name.

Follow what brew suggested:


mkdir -p /Users/ernestyeung/Library/Python/2.7/lib/python/site-packages
echo 'import site; site.addsitedir("/usr/local/lib/python2.7/site-packages")' >> /Users/ernestyeung/Library/Python/2.7/lib/python/site-packages/homebrew.pth

Then do brew info vtk to check.

Install Mayavi

sudo pip install mayavi

Install Scrapy 1.0 on a Mac OSX

Scrapy 1.0 needs an updated six.

sudo easy_install six

cf. Scrapy throws ImportError: cannot import name xmlrpc_client ; see Dan Banks’ answer

Scrapy should then work even if you already installed it beforehand with pip.

Advertisements

One thought on “update Homebrew, install vtk, ImportError, link vtk to import vtk, install mayavi, installing Scrapy, on Mac OSX Yosemite

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s