【问题标题】:Installing hashLib gives SyntaxError: Missing parentheses in call to 'print'安装 hashLib 会出现 SyntaxError: Missing parentheses in call to 'print'
【发布时间】:2019-11-26 05:55:42
【问题描述】:

我需要一个简单的密码哈希函数,并认为我可以使用hashlib。 PyCharm 建议通过运行pip install hashLib 来安装它。

但是现在 PyCharm 正在抱怨库中的语法错误:

Collecting hashLib
Using cached https://files.pythonhosted.org/packages/74/bb/9003d081345e9f0451884146e9ea2cff6e4cc4deac9ffd4a9ee98b318a49/hashlib-20081119.zip
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/private/var/folders/6_/8g1vyy5n1t1859x2d30ssk480000gn/T/pycharm-packaging/hashLib/setup.py", line 68
    print "unknown OS, please update setup.py"
          ^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print("unknown OS, please update setup.py")?

----------------------------------------

Command "python setup.py egg_info" failed with error code 1 in /private/var/folders/6_/8g1vyy5n1t1859x2d30ssk480000gn/T/pycharm-packaging/hashLib/

这表明这可能与我正在使用的 Python 版本有关(我尝试使用 Python 2.7 和 Python 3.8,但它们都不起作用)。

确保您使用的是此软件包支持的 Python 版本。 目前您使用的是 Python 3.8。

【问题讨论】:

  • 你是怎么安装的?
  • 在项目解释器中添加并安装包hashlib
  • 您对标准库中的hashlib 不满意?
  • "这是 Python 2.5 中包含的 hashlib 库的独立打包,因此可以在旧版本的 Python 上使用(在 2.3 和 2.4 上测试)。"
  • 是的...我明白了,但 PyCharm 建议我这个解决方案(安装 hashlib)

标签: python pycharm hashlib


【解决方案1】:

hashlib 现在在标准库中。这意味着您不需要安装它,它已经在您的 Python 安装中。

您尝试从 PyPI 安装的版本适用于 非常 旧版本的 Python (

【讨论】:

  • 但是当我尝试导入它时,我得到了错误,它建议我: "pip install hashLib" 。所以我在终端里做,还是不行。它抱怨括号拼写错误。
  • 我认为这只是 PyCharm 愚蠢。将导入更改为 hashlib 而不是 hashLib
  • 好的,现在我遇到了另一种类型的错误:“TypeError: 'frozenset' object is not callable”
  • 看起来 hashLib 问题解决了不是吗?至于frozenset问题,那就是different question,考虑单独发一下。
  • 不,不...实际上我遇到了同样的错误。一旦我尝试从终端下载 hashlib,我就遇到了 freezeset 问题。但是现在我总是遇到拼写错误
猜你喜欢
  • 2018-11-17
  • 1970-01-01
  • 2014-10-16
  • 2016-12-26
  • 2022-12-02
  • 1970-01-01
  • 1970-01-01
  • 2016-11-25
相关资源
最近更新 更多