1

I'm unable to import numpy in Python 2.7 in the shell. I installed Python with brew install, then numpy with sudo pip install. I tried without sudo but I get a permission denied error. Anyway, I get this:

ImportError: dlopen(/usr/local/Cellar/python/2.7.10_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload/_io.so, 2): Symbol not found: __PyErr_ReplaceException

Referenced from: /usr/local/Cellar/python/2.7.10_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload/_io.so
  Expected in: flat namespace

 in /usr/local/Cellar/python/2.7.10_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload/_io.so

In /usr/local/bin/ I have the following:

pip
pip2
pip2.7
pip3
pip3.4

And:

python
python-config
python2
python2-config
python2.7
python2.7-config
python3
python3-config
python3.4
python3.4-config
python3.4m
python3.4m-config
pythonw
pythonw2
pythonw2.7

The output of which python is /usr/local/bin/python

Ada Stra
  • 1,501
  • 3
  • 13
  • 14

2 Answers2

1

That output is normal. Have you tried running brew install openssl followed by brew link --force openssl and then brew install python. The following thread helps describe the issue https://github.com/Homebrew/homebrew/issues/40516

Garrett Kadillak
  • 1,026
  • 9
  • 18
  • thanks for reassuring me that the output is normal! I tried that solution, but it didn't work. Usually I use 3.4, and it's working great, as a workaround for when I use 2.7, could I simply create a virtual environment? This wouldn't fix the original issue, but I'd have a clean version of 2.7? – Ada Stra Aug 08 '15 at 17:30
  • 1
    Yes that's how I use python 3.4 on my system :) – Garrett Kadillak Aug 08 '15 at 18:57
1

As for workaround, try downgrading your Python to 2.7.9 like:

brew switch python 2.7.9

by overriding the existing one, as it seems there is some particular problem with 2.7.10. Then re-link it again (if required).

Also make sure your PYTHONPATH is correct (you don't override it anywhere in your startup files).

kenorb
  • 155,785
  • 88
  • 678
  • 743
  • 1
    THANKS! Before trying the downgraded version I checked the PYTHONPATH and that's where the problem was. – Ada Stra Aug 08 '15 at 17:55