問題描述
Python 在 Mac 上意外退出 (Python quit unexpectedly on Mac)
我已經從這裡
安裝了python3當我嘗試運行'python3',它退出並提供以下信息:
致命的 Python 錯誤:Py_Initialize:無法加載文件系統編解碼器 ImportError: No module named 'encodings'
Current線程 0x00007fff960a93c0(最近一次調用優先):中止陷阱:6
在此之前,我嘗試從 Homebrew 安裝 python3。
我不記得我是否有刪除 /Library/Frameworks/Python.framework
os : macOS
順便說一下,IDLE 運行良好/Library/Frameworks/Python.framework
/p>
參考解法
方法 1:
If you are using Homebrew, you can reinstall a corrupted Python environment like this:
brew uninstall ‑‑ignore‑dependencies ‑‑force python python@2
unset PYTHONPATH
brew install python python@2
I had a similar "quit unexpectedly" issue and this resolved it for me. pip
and pip3
are both working fine after without messing with them.
方法 2:
brew reinstall openssl
Then:
cd /usr/local/lib
sudo ln ‑s /usr/local/opt/openssl/lib/libssl.dylib libssl.dylib
sudo ln ‑s /usr/local/opt/openssl/lib/libcrypto.dylib libcrypto.dylib
(by ringsaturn、statueofmike、Brandon Stewart)
參考文件