Fatal Python error: Py_Initialize: unable to load the file system codec

打开terminal报错
Could not find platform independent libraries <prefix>
Could not find platform dependent libraries <exec_prefix>
Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>]
Fatal Python error: Py_Initialize: unable to load the file system codec
ModuleNotFoundError: No module named 'encodings'

分析原因:
想清理python的安装版本,删掉一些文件后就出现如此了,手贱……

解决:

1. sudo vim /etc/profile/
2. export PYTHONHOME=/Library/Frameworks/Python.framework/Versions/3.7
export PYTHONPATH=.:$PYTHONHOME/bin:$PYTHONHOME/site-packages
export PATH=$PATH:$PYTHONHOME:$PYTHONP

运行之后报错

Fatal Python error: Py_Initialize: unable to load the file system codec
ModuleNotFoundError: No module named 'encodings'

继续修改
删掉关于anaconda有关的环境变量

perfect!

猜你喜欢

转载自blog.csdn.net/weixin_40161254/article/details/88576220