我的Mac上的Python很乱,帮我卸载我不需要的东西

时间:2015-08-07 22:45:13

标签: python macos numpy

我无法在shell中导入Python 2.7中的numpy。我用brew install安装了Python,然后用sudo pip install安装了numpy。我试过没有sudo但是我得到了一个权限被拒绝的错误。无论如何,我明白了:

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

/usr/local/bin/我有以下内容:

pip
pip2
pip2.7
pip3
pip3.4

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

which python的输出为/usr/local/bin/python

2 个答案:

答案 0 :(得分:1)

输出正常。您是否尝试过public static class MyErrorListener implements ErrorListener { private ArrayList<String> messages = new ArrayList<String>(); public void fatalError(TransformerException e) throws TransformerException { messages.add(e); throw e; //This is reached, but never caught on the top level } public List<String> getMessages() { return messages; } } 后跟brew install openssl然后brew link --force openssl。以下主题有助于描述问题https://github.com/Homebrew/homebrew/issues/40516

答案 1 :(得分:1)

至于解决方法,请尝试将Python降级为2.7.9,如:

brew switch python 2.7.9

通过覆盖现有的,因为2.7.10似乎存在一些特殊问题。然后再次重新链接(如果需要)。

另外请确保您的PYTHONPATH正确无误(您不要在启动文件中的任何位置覆盖它)。