0

I used brew to install python 2.7 and 3.5 on Mac. SOMEHOW I have this site-packages directory /usr/local/lib/python2.7/site-packages.

But every python interpreter on the system points to every other site-packages directory EXCEPT this one. How do I use THIS site-packages directory?

(This is all because I need Vips. I'd installed this before, but now I'm using a different machine and I can't figure out how on Earth I got it to work before.)

2 Answers2

0

The vips docs have a checklist and an explanation of what happens when Python tried to import vips:

http://www.vips.ecs.soton.ac.uk/supported/current/doc/html/libvips/using-from-python.html

But briefly you need to:

  • You have several Pythons installed, make sure you are invoking the brew one.

  • Make sure that that Python has a gi repository containing the Vips.py overrides.

  • Make sure you have a Vips-8.0.typelib file in /usr/local/lib/lib/girepository-1.0/.

jcupitt
  • 10,213
  • 2
  • 23
  • 39
  • I said: "I used brew to install python 2.7 and 3.5 on Mac." So yes, brew is installed. Now... Let me put it this way -- when running Python code, it cannot locate the Vips file. I say "from gi.repository import Vips". I HAVE the Vips code here /usr/local/lib/python2.7/site-packages. So why can't it find it? My PATH is set with /usr/local/lib first in the path. What should I do to troubleshoot this? Because there really seems to be no logical explanation as to why the python interpreter cannot find the file that is clearly in this site-packages directory. –  Feb 28 '16 at 22:17
  • I updated the answer, does that help? Maybe also add the exact error message you are seeing to your question. – jcupitt Feb 29 '16 at 07:43
  • OK yes that helps. Thanks. /usr/local/lib/girepository-1.0/ contains Vips-8.0.typelib. And I have /usr/local/lib/gobject-introspection/. When you say "Make sure that that Python has a gi repository", you mean in Python's site-packages directory, right? If so then /usr/local/lib/python2.7/site-packages/gi/overrides/ contains Vips.py and Vips.pyo. So far so good. Make sure I'm invoking the right Python. python2.7 is the one that has gi. When I use that python and invoke "from gi.overrides import Vips" it says "ImportError: No module named overrides". –  Feb 29 '16 at 16:51
  • When I use python3 (which should *not* work), the error is: "File "/usr/local/lib/python3.5/site-packages/gi/__init__.py", line 39 print url ^ SyntaxError: Missing parentheses in call to 'print'". So it's finding a gi in that directory but it only has __init__.py. When I say "pip3 install --upgrade gi", it says "Requirement already up-to-date: gi in /usr/local/lib/python3.5/site-packages". –  Feb 29 '16 at 16:52
0

SOLVED. I didn't want to have to resort to resetting my dev box to factory settings, but I did. I hope this helps somebody...

If Python already exists on your system, and you're planning on installing Python yourself or with Homebrew (because you only get python2.7 out of the box), make sure you install the new Python first. Then put the install location first in your PATH. Then install your modules. In that order. I knew something was wrong, so I uninstalled Python/3 and Vips. But when I reinstalled them, for whatever reason Vips still didn't know to bind itself to the Python in /usr/local/Cellar. Even though I had /usr/local/Cellar first in PATH.

So to recap -- first install Homebrew, then set the PATH, then install python/python3, and finally install Vips. And you're good to go.