推荐学习书目
› Learn Python the Hard Way
Python Sites
› PyPI - Python Package Index
› 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 · Mar 26, 2020 · 5996 views
    This topic created in 2413 days ago, the information mentioned may be changed or developed.

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

    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

    32 replies  •  2020-04-08 16:26:16 +08:00
    TimePPT
    TimePPT
    Mar 26, 2020
    1
    卸了重装吧
    另外,建议用 pyenv 直接管理 Python 版本吧,想咋折腾咋折腾
    wangyzj
    wangyzj
    Mar 26, 2020
    2
    哈哈
    你犯了大忌了
    misaka19000
    misaka19000
    Mar 26, 2020
    3
    降低 openssl 的版本
    Hanggi
    Hanggi
    Mar 26, 2020
    4
    放弃 py 吧,真的是一坨浆糊,不想用。
    oahebky
    oahebky
    Mar 26, 2020
    5
    重装警告
    重装警告
    重装警告
    Ccbeango
    Ccbeango
    Mar 26, 2020
    6
    用 py 版本管理工具多好啊。
    abelzyp
    abelzyp
    OP
    Mar 26, 2020
    7
    @wangyzj 对于你这种在一旁冷笑,站着说话不腰疼的这类人。我只能对你说:大佬,我是真不知道这是啥报错啊?救救孩子吧😭
    wangyzj
    wangyzj
    Mar 26, 2020
    8
    环境变量改成 /Library/Frameworks/Python.framework/Versions 下面的试试
    jiejiss
    jiejiss
    Mar 26, 2020
    10
    brew install openssl
    brew link openssl --force
    brew uninstall python
    brew install python --with-brewed-openssl
    abelzyp
    abelzyp
    OP
    Mar 26, 2020
    11
    我刚才照着这个帖子 https://www.jianshu.com/p/98383a7688a5 删除了 Python3.7 和 2.7,还是不行。求指教啊?
    我现在 ls /Library/Frameworks/Python.framework/Versions 只有一个 Current,剩下啥都没了。
    WoodenRobot
    WoodenRobot
    Mar 26, 2020
    12
    []( https://zhuanlan.zhihu.com/p/117457048) 试试这个,我之前遇到过
    abelzyp
    abelzyp
    OP
    Mar 26, 2020
    13
    @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
    Cuo
    Mar 26, 2020
    14
    可以换用 pyenv 管理 python 版本,将 pyenv 下的 python 路径设为全局变量后就可以无视 brew 安装的 python 了。
    wangyzj
    wangyzj
    Mar 26, 2020
    15
    @abelzyp 有 timemachine 吗?
    U7Q5tLAex2FI0o0g
    U7Q5tLAex2FI0o0g
    Mar 26, 2020
    16
    我想问一下你一开始有 brew update 么
    Cuo
    Cuo
    Mar 26, 2020
    17
    @abelzyp 你在删除的是系统自带的 python,如果按照提示强制删除的话,之后可能出现依赖问题
    abelzyp
    abelzyp
    OP
    Mar 26, 2020
    18
    @littleylv 执行 brew install python --with-brewed-openssl 的时候报错:Error: invalid option: --with-brewed-openssl,这块是命令不对么?我着实不太了解这块。
    abelzyp
    abelzyp
    OP
    Mar 26, 2020
    19
    @Cuo 那可否装回来啊?我看通过 10 楼的最后一条命令,应该是装回来的意思吧?
    abelzyp
    abelzyp
    OP
    Mar 26, 2020
    20
    @littleylv 有的,这块有什么联系么?
    gitopen
    gitopen
    Mar 26, 2020
    21
    pyenv 最好用!
    ivyliner
    ivyliner
    Mar 26, 2020 via Android
    22
    conda 真香
    wzwwzw
    wzwwzw
    Mar 26, 2020
    23
    Python 别升级啊,直接重装啊。
    jiejiss
    jiejiss
    Mar 26, 2020
    24
    @abelzyp #19 是的。按照提示来
    justin2018
    justin2018
    Mar 26, 2020
    25
    不要删除系统自带的

    可以 brew install python3

    安装好了后 python3 就是 3.xx 版本 python 是 2.xx 版本
    abelzyp
    abelzyp
    OP
    Mar 26, 2020
    26
    @misaka19000
    @WoodenRobot
    两位大佬,我想问下,我这个错误与 OpenSSL 的关系是啥呢?我这边对这个问题不是很了解,刚接触。
    Livid
    Livid
    MOD
    PRO
    Mar 26, 2020
    27
    misaka19000
    misaka19000
    Mar 26, 2020
    28
    @abelzyp #25 因为我前几天遇到了和你一模一样的问题,后来在网上查找资料,最后就是通过给 openssl 降级解决的,从 1.1.1 降级到 1.0.2
    abelzyp
    abelzyp
    OP
    Mar 26, 2020
    29
    现在看来,下面四条命令是最好用的:
    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
    xingheng
    Mar 26, 2020
    30
    用 brew 安装 python 的你就是作死,死的透透的你就顿悟了。
    wangyzj
    wangyzj
    Mar 27, 2020
    31
    @abelzyp 复制一份过去吧
    最好的办法是恢复
    你的系统自带的已经不见了
    不知道为啥
    或者给你打个包你放到那个路径试试
    Mark24
    Mark24
    Apr 8, 2020
    32
    brew 安装会编译,这是编译 Python 的时候,依赖有点问题。

    卸掉,先装上编译 Python 需要的依赖,再安装 Python
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   5197 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 61ms · UTC 07:01 · PVG 15:01 · LAX 23:01 · JFK 02:01
    ♥ Do have faith in what you're doing.