V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
推荐学习书目
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 · 2020-03-26 13:19:46 +08:00 · 4688 次点击
    这是一个创建于 1704 天前的主题,其中的信息可能已经有所发展或是发生改变。

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

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

    可以 brew install python3

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

    卸掉,先装上编译 Python 需要的依赖,再安装 Python
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   2892 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 26ms · UTC 12:31 · PVG 20:31 · LAX 04:31 · JFK 07:31
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.