【问题标题】:A python3 virtualenv and am trying to create Django project. I see "ERROR:root:code for hash md5 was not found" with python2.7 mentioned in the error?一个 python3 virtualenv 并正在尝试创建 Django 项目。我看到错误中提到的python2.7“错误:root:找不到哈希md5的代码”?
【发布时间】:2020-06-17 10:00:02
【问题描述】:

我用python3 -m venv env创建了一个virtualenv, 激活envwhich pythonpython --version 确认我的环境处于活动状态并正在运行 Python 3.6.1。然后我用pip install django 安装了django。然后django-admin startproject project这个命令创建了一个项目但是返回如下:

ERROR:root:code for hash md5 was not found.
Traceback (most recent call last):
  File "/usr/local/Cellar/python/2.7.11/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.11/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.11/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.11/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.11/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.11/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.11/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.11/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.11/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.11/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.11/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.11/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

然后我跑了

cd project
django-admin startapp account

同样的事情,创建了应用但返回了同样的错误/警告。

我注意到python2.7 在这个错误中出现了很多。当我激活env 并进入交互式控制台时,它显示它正在运行 python 3.6,不确定这里发生了什么。这些命令正在做他们应该做的事情,但抛出了这个错误,所以甚至不确定这是否是我应该担心的事情?谢谢你的帮助。

编辑:我觉得我已经创建了 python3 虚拟环境并设置了 django 项目很多次都没有问题。最近部署了我的第一个项目,我想也许我可能在我的机器上搞砸了?我看到与此错误相关的其他问题,请参阅 ssl... 我按照这里的建议尝试了brew unlink openssl ERROR:root:code for hash md5 was not found - not able to use any hg mercurial commands,但没有奏效。

最后很抱歉标题措辞不佳,我不得不尝试用 150 个字符来传达问题。

【问题讨论】:

  • which python 会告诉你source env/bin/activate 是否有效。
  • @KeithJohnHutchison 不知道这一点,但它返回 /Users/justin/Desktop/social/env/bin/python 所以它使用环境
  • python --version 会确认你激活了哪个版本的python
  • @KeithJohnHutchison Python 3.6.1... 似乎这个错误遍布整个互联网。我见过的解决方案都没有帮助,但看起来像是 python 问题而不是 django 问题?
  • 返回 pip 20.0.2 from /Users/justin/Desktop/social/env/lib/python3.6/site-packages/pip 。尝试使用 pip3 创建一个新的环境/项目,没有效果。将尝试升级python,感谢您到目前为止的帮助。

标签: python django virtualenv


【解决方案1】:

brew 不再支持 python@2.7。

我通过删除 brew python 2.7 然后使用 sudo pip3 安装 virtualenv 来消除错误消息。

请注意,这将导致设备上使用 brew python 2.7 虚拟环境的任何旧项目出现问题。

brew uninstall python@2.7
sudo pip3 install virtualenv

【讨论】:

    【解决方案2】:

    我在创建新环境时遇到了类似的问题。

    但是...安装 django 有效。

    csmu:test-for-justin admin$ virtualenv -p python3 env-test-for-justin
    ERROR:root:code for hash md5 was not found.
    Traceback (most recent call last):
      File "/usr/local/Cellar/python@2/2.7.16/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/2.7.16/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/2.7.16/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/2.7.16/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/2.7.16/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/2.7.16/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/2.7.16/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/2.7.16/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/2.7.16/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/2.7.16/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/2.7.16/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/2.7.16/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
    Running virtualenv with interpreter /usr/local/bin/python3
    Already using interpreter /usr/local/opt/python/bin/python3.7
    Using base prefix '/usr/local/Cellar/python/3.7.6_1/Frameworks/Python.framework/Versions/3.7'
    New python executable in /Users/admin/source/test-for-justin/env-test-for-justin/bin/python3.7
    Not overwriting existing python script /Users/admin/source/test-for-justin/env-test-for-justin/bin/python (you must use /Users/admin/source/test-for-justin/env-test-for-justin/bin/python3.7)
    Installing setuptools, pip, wheel...
    done.
    
    
    source env-test-for-justin/bin/activate
    
    pip install django
    Collecting django
      Using cached Django-3.0.4-py3-none-any.whl (7.5 MB)
    Collecting sqlparse>=0.2.2
      Using cached sqlparse-0.3.1-py2.py3-none-any.whl (40 kB)
    Collecting pytz
      Using cached pytz-2019.3-py2.py3-none-any.whl (509 kB)
    Collecting asgiref~=3.2
      Using cached asgiref-3.2.3-py2.py3-none-any.whl (18 kB)
    Installing collected packages: sqlparse, pytz, asgiref, django
    Successfully installed asgiref-3.2.3 django-3.0.4 pytz-2019.3 sqlparse-0.3.1
    
    django-admin startproject api .
    
    ./manage.py migrate
    (env-test-for-justin) csmu:test-for-justin admin$ ./manage.py runserver
    Watching for file changes with StatReloader
    Performing system checks...
    
    System check identified no issues (0 silenced).
    March 05, 2020 - 00:56:19
    Django version 3.0.4, using settings 'api.settings'
    Starting development server at http://127.0.0.1:8000/
    

    【讨论】:

      猜你喜欢
      • 2017-06-07
      • 2020-03-22
      • 2020-05-30
      • 1970-01-01
      • 2020-05-19
      • 1970-01-01
      • 2020-04-03
      相关资源
      最近更新 更多