本文介绍了Mac上的Python很乱,请帮我卸载我不需要的东西的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我无法在Shell的Python 2.7中导入numpy.我用brew install安装了Python,然后用sudo pip install安装了numpy.我尝试了不使用sudo的情况,但出现了权限被拒绝的错误.无论如何,我得到了:

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

/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

推荐答案

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

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

brew switch python 2.7.9

通过覆盖现有的

,似乎在2.7.10中存在一些特殊问题.然后再次重新链接(如果需要).

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

还要确保您的PYTHONPATH是正确的(不要在启动文件中的任何位置覆盖它).

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

这篇关于Mac上的Python很乱,请帮我卸载我不需要的东西的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-16 03:00
查看更多