重置路径和PYTHONPATH

重置路径和PYTHONPATH,python,macos,python-3.x,homebrew,Python,Macos,Python 3.x,Homebrew,我在Mac电脑上通过自制程序安装了Python 3.5.1,每当我在终端上运行Python,甚至python3,它都会引发以下错误: Fatal Python error: Py_Initialize: unable to load the file system codec File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/encodings/__init__.py", line 123

我在Mac电脑上通过自制程序安装了Python 3.5.1,每当我在终端上运行
Python
,甚至
python3
,它都会引发以下错误:

Fatal Python error: Py_Initialize: unable to load the file system codec
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/encodings/__init__.py", line 123
    raise CodecRegistryError,\
                            ^
SyntaxError: invalid syntax

Current thread 0x00007fff78ab9000 (most recent call first):
Abort trap: 6
我意识到这可能是由于运行的是Python2.7而不是Python3,这一定是由于我的
$PATH
中的一个错误,因为每当我运行
Python--version
,输出都是
Python3.5.1

/usr/bin/python
是可执行文件,我相信是2.7版

/usr/local/bin/python3.5
/Library/Frameworks/Python.framework/Versions/3.5/bin/python3.5

这是
~/.bash\u配置文件
文件内容

export PYTHONPATH=/Library/Frameworks/SQLite3.framework/Versions/3/Python:/Library/Python/2.7/site-packages/numpy-override:/Library/Frameworks/GDAL.framework/Versions/1.7/Python/site-packages:/Library/Frameworks/cairo.framework/Versions/1/Python:/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python26.zip:/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7:/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-darwin:/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac:/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac/lib-scriptpackages:/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python:/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python22.7.6/lib-tk:/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-old:/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload:/Library/Python/2.7/site-packages:/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/PyObjC:/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/wx-2.8-mac-unicode:/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/:/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages:/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/:/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages:/Users/Sasha/PyQt-gpl-5.5.1:/Users/Sasha/Library/Python/2.7/lib/python/PyQt-gpl-5.5.1
# Setting PATH for Python 3.5
# The orginal version is saved in .bash_profile.pysave
PATH="/Library/Frameworks/Python.framework/Versions/3.5/bin:${PATH}"
export PATH
alias python="python3"

您在
PYTHONPATH
中放置了很多python2库,您是否尝试过在
bash
窗口(
unset PYTHONPATH
)中删除
PHTHONPATH
)并运行
Python