首页   注册   登录
V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
推荐学习书目
Learn Python the Hard Way
Python 学习手册
Python Cookbook
Python 基础教程
Python Sites
PyPI - Python Package Index
http://www.simple-is-better.com/
http://diveintopython.org/toc/index.html
Pocoo
值得关注的项目
PyPy
Celery
Jinja2
Read the Docs
gevent
pyenv
virtualenv
Stackless Python
Beautiful Soup
结巴中文分词
Green Unicorn
Sentry
Shovel
Pyflakes
pytest
Python 编程
pep8 Checker
Styles
PEP 8
Google Python Style Guide
Code Style from The Hitchhiker's Guide
阿里云
abelzyp
V2EX  ›  Python

MacOS 通过 Brew 升级完 Python 打开终端出现一堆错误。

  •  1
     
  •   abelzyp · 2 天前 · 1506 次点击

    打开终端就出现如下错误,求帮助:

    ERROR:root:code for hash md5 was not found. Traceback (most recent call last): File "/usr/local/Cellar/python/2.7.13/Frameworks/Python.framework/Versions/2.7/lib/python2.7/hashlib.py", line 147, in <module> globals()[__func_name] = __get_hash(__func_name) File "/usr/local/Cellar/python/2.7.13/Frameworks/Python.framework/Versions/2.7/lib/python2.7/hashlib.py", line 97, in __get_builtin_constructor raise ValueError('unsupported hash type ' + name) ValueError: unsupported hash type md5 ERROR:root:code for hash sha1 was not found. Traceback (most recent call last): File "/usr/local/Cellar/python/2.7.13/Frameworks/Python.framework/Versions/2.7/lib/python2.7/hashlib.py", line 147, in <module> globals()[__func_name] = __get_hash(__func_name) File "/usr/local/Cellar/python/2.7.13/Frameworks/Python.framework/Versions/2.7/lib/python2.7/hashlib.py", line 97, in __get_builtin_constructor raise ValueError('unsupported hash type ' + name) ValueError: unsupported hash type sha1 ERROR:root:code for hash sha224 was not found. Traceback (most recent call last): File "/usr/local/Cellar/python/2.7.13/Frameworks/Python.framework/Versions/2.7/lib/python2.7/hashlib.py", line 147, in <module> globals()[__func_name] = __get_hash(__func_name) File "/usr/local/Cellar/python/2.7.13/Frameworks/Python.framework/Versions/2.7/lib/python2.7/hashlib.py", line 97, in __get_builtin_constructor raise ValueError('unsupported hash type ' + name) ValueError: unsupported hash type sha224 ERROR:root:code for hash sha256 was not found. Traceback (most recent call last): File "/usr/local/Cellar/python/2.7.13/Frameworks/Python.framework/Versions/2.7/lib/python2.7/hashlib.py", line 147, in <module> globals()[__func_name] = __get_hash(__func_name) File "/usr/local/Cellar/python/2.7.13/Frameworks/Python.framework/Versions/2.7/lib/python2.7/hashlib.py", line 97, in __get_builtin_constructor raise ValueError('unsupported hash type ' + name) ValueError: unsupported hash type sha256 ERROR:root:code for hash sha384 was not found. Traceback (most recent call last): File "/usr/local/Cellar/python/2.7.13/Frameworks/Python.framework/Versions/2.7/lib/python2.7/hashlib.py", line 147, in <module> globals()[__func_name] = __get_hash(__func_name) File "/usr/local/Cellar/python/2.7.13/Frameworks/Python.framework/Versions/2.7/lib/python2.7/hashlib.py", line 97, in __get_builtin_constructor raise ValueError('unsupported hash type ' + name) ValueError: unsupported hash type sha384 ERROR:root:code for hash sha512 was not found. Traceback (most recent call last): File "/usr/local/Cellar/python/2.7.13/Frameworks/Python.framework/Versions/2.7/lib/python2.7/hashlib.py", line 147, in <module> globals()[__func_name] = __get_hash(__func_name) File "/usr/local/Cellar/python/2.7.13/Frameworks/Python.framework/Versions/2.7/lib/python2.7/hashlib.py", line 97, in __get_builtin_constructor raise ValueError('unsupported hash type ' + name) ValueError: unsupported hash type sha512 ERROR:root:code for hash md5 was not found. Traceback (most recent call last): File "/usr/local/Cellar/python/2.7.13/Frameworks/Python.framework/Versions/2.7/lib/python2.7/hashlib.py", line 147, in <module> globals()[__func_name] = __get_hash(__func_name) File "/usr/local/Cellar/python/2.7.13/Frameworks/Python.framework/Versions/2.7/lib/python2.7/hashlib.py", line 97, in __get_builtin_constructor raise ValueError('unsupported hash type ' + name) ValueError: unsupported hash type md5 ERROR:root:code for hash sha1 was not found. Traceback (most recent call last): File "/usr/local/Cellar/python/2.7.13/Frameworks/Python.framework/Versions/2.7/lib/python2.7/hashlib.py", line 147, in <module> globals()[__func_name] = __get_hash(__func_name) File "/usr/local/Cellar/python/2.7.13/Frameworks/Python.framework/Versions/2.7/lib/python2.7/hashlib.py", line 97, in __get_builtin_constructor raise ValueError('unsupported hash type ' + name) ValueError: unsupported hash type sha1 ERROR:root:code for hash sha224 was not found. Traceback (most recent call last): File "/usr/local/Cellar/python/2.7.13/Frameworks/Python.framework/Versions/2.7/lib/python2.7/hashlib.py", line 147, in <module> globals()[__func_name] = __get_hash(__func_name) File "/usr/local/Cellar/python/2.7.13/Frameworks/Python.framework/Versions/2.7/lib/python2.7/hashlib.py", line 97, in __get_builtin_constructor raise ValueError('unsupported hash type ' + name) ValueError: unsupported hash type sha224 ERROR:root:code for hash sha256 was not found. Traceback (most recent call last): File "/usr/local/Cellar/python/2.7.13/Frameworks/Python.framework/Versions/2.7/lib/python2.7/hashlib.py", line 147, in <module> globals()[__func_name] = __get_hash(__func_name) File "/usr/local/Cellar/python/2.7.13/Frameworks/Python.framework/Versions/2.7/lib/python2.7/hashlib.py", line 97, in __get_builtin_constructor raise ValueError('unsupported hash type ' + name) ValueError: unsupported hash type sha256 ERROR:root:code for hash sha384 was not found. Traceback (most recent call last): File "/usr/local/Cellar/python/2.7.13/Frameworks/Python.framework/Versions/2.7/lib/python2.7/hashlib.py", line 147, in <module> globals()[__func_name] = __get_hash(__func_name) File "/usr/local/Cellar/python/2.7.13/Frameworks/Python.framework/Versions/2.7/lib/python2.7/hashlib.py", line 97, in __get_builtin_constructor raise ValueError('unsupported hash type ' + name) ValueError: unsupported hash type sha384 ERROR:root:code for hash sha512 was not found. Traceback (most recent call last): File "/usr/local/Cellar/python/2.7.13/Frameworks/Python.framework/Versions/2.7/lib/python2.7/hashlib.py", line 147, in <module> globals()[__func_name] = __get_hash(__func_name) File "/usr/local/Cellar/python/2.7.13/Frameworks/Python.framework/Versions/2.7/lib/python2.7/hashlib.py", line 97, in __get_builtin_constructor raise ValueError('unsupported hash type ' + name) ValueError: unsupported hash type sha512

    31 条回复    2020-03-27 00:19:41 +08:00
    TimePPT
        1
    TimePPT   2 天前
    卸了重装吧
    另外,建议用 pyenv 直接管理 Python 版本吧,想咋折腾咋折腾
    wangyzj
        2
    wangyzj   2 天前
    哈哈
    你犯了大忌了
    misaka19000
        3
    misaka19000   2 天前
    降低 openssl 的版本
    Hanggi
        4
    Hanggi   2 天前
    放弃 py 吧,真的是一坨浆糊,不想用。
    oahebky
        5
    oahebky   2 天前
    重装警告
    重装警告
    重装警告
    Ccbeango
        6
    Ccbeango   2 天前
    用 py 版本管理工具多好啊。
    abelzyp
        7
    abelzyp   2 天前
    @wangyzj 对于你这种在一旁冷笑,站着说话不腰疼的这类人。我只能对你说:大佬,我是真不知道这是啥报错啊?救救孩子吧😭
    wangyzj
        8
    wangyzj   2 天前
    环境变量改成 /Library/Frameworks/Python.framework/Versions 下面的试试
    jiejiss
        10
    jiejiss   2 天前
    brew install openssl
    brew link openssl --force
    brew uninstall python
    brew install python --with-brewed-openssl
    abelzyp
        11
    abelzyp   2 天前
    我刚才照着这个帖子 https://www.jianshu.com/p/98383a7688a5 删除了 Python3.7 和 2.7,还是不行。求指教啊?
    我现在 ls /Library/Frameworks/Python.framework/Versions 只有一个 Current,剩下啥都没了。
    WoodenRobot
        12
    WoodenRobot   2 天前
    []( https://zhuanlan.zhihu.com/p/117457048) 试试这个,我之前遇到过
    abelzyp
        13
    abelzyp   2 天前
    @jiejiss 在执行 brew uninstall python 的时候,错误如下:
    Error: Refusing to uninstall /usr/local/Cellar/python/2.7.13
    because it is required by macvim and vim, which are currently installed.
    You can override this and force removal with:
    brew uninstall --ignore-dependencies python

    我是应该按照提示进行么?
    Cuo
        14
    Cuo   2 天前
    可以换用 pyenv 管理 python 版本,将 pyenv 下的 python 路径设为全局变量后就可以无视 brew 安装的 python 了。
    wangyzj
        15
    wangyzj   2 天前
    @abelzyp 有 timemachine 吗?
    littleylv
        16
    littleylv   2 天前
    我想问一下你一开始有 brew update 么
    Cuo
        17
    Cuo   2 天前
    @abelzyp 你在删除的是系统自带的 python,如果按照提示强制删除的话,之后可能出现依赖问题
    abelzyp
        18
    abelzyp   2 天前
    @littleylv 执行 brew install python --with-brewed-openssl 的时候报错:Error: invalid option: --with-brewed-openssl,这块是命令不对么?我着实不太了解这块。
    abelzyp
        19
    abelzyp   2 天前
    @Cuo 那可否装回来啊?我看通过 10 楼的最后一条命令,应该是装回来的意思吧?
    abelzyp
        20
    abelzyp   2 天前
    @littleylv 有的,这块有什么联系么?
    gitopen
        21
    gitopen   2 天前
    pyenv 最好用!
    ivyliner
        22
    ivyliner   2 天前 via Android
    conda 真香
    wzwwzw
        23
    wzwwzw   2 天前
    Python 别升级啊,直接重装啊。
    jiejiss
        24
    jiejiss   2 天前
    @abelzyp #19 是的。按照提示来
    justin2018
        25
    justin2018   2 天前
    不要删除系统自带的

    可以 brew install python3

    安装好了后 python3 就是 3.xx 版本 python 是 2.xx 版本
    abelzyp
        26
    abelzyp   2 天前
    @misaka19000
    @WoodenRobot
    两位大佬,我想问下,我这个错误与 OpenSSL 的关系是啥呢?我这边对这个问题不是很了解,刚接触。
    Livid
        27
    Livid   V2EX Moderator   2 天前
    misaka19000
        28
    misaka19000   2 天前
    @abelzyp #25 因为我前几天遇到了和你一模一样的问题,后来在网上查找资料,最后就是通过给 openssl 降级解决的,从 1.1.1 降级到 1.0.2
    abelzyp
        29
    abelzyp   2 天前
    现在看来,下面四条命令是最好用的:
    brew install openssl
    brew link openssl --force
    brew uninstall python
    brew install python --with-brewed-openssl
    但是我最后一条命令执行不成功,原因在上面我说了。
    现在执行完成前三条命令后,我现在的报错信息已经是下面这个了,有人遇到过吗🤦‍♂️

    /usr/local/lib/python2.7/site-packages/powerline/bindings/bash/powerline.sh:99: /usr/local/bin/powerline-config: bad interpreter: /usr/local/opt/python/bin/python2.7: no such file or directory
    /usr/local/lib/python2.7/site-packages/powerline/bindings/bash/powerline.sh:102: /usr/local/bin/powerline-config: bad interpreter: /usr/local/opt/python/bin/python2.7: no such file or directory
    xingheng
        30
    xingheng   2 天前
    用 brew 安装 python 的你就是作死,死的透透的你就顿悟了。
    wangyzj
        31
    wangyzj   1 天前
    @abelzyp 复制一份过去吧
    最好的办法是恢复
    你的系统自带的已经不见了
    不知道为啥
    或者给你打个包你放到那个路径试试
    关于   ·   FAQ   ·   API   ·   我们的愿景   ·   广告投放   ·   感谢   ·   实用小工具   ·   2608 人在线   最高记录 5168   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 34ms · UTC 15:36 · PVG 23:36 · LAX 08:36 · JFK 11:36
    ♥ Do have faith in what you're doing.