代码之家  ›  专栏  ›  技术社区  ›  Calcutta

将Web3导入Google Colab时出错

  •  0
  • Calcutta  · 技术社区  · 5 年前

    我正在尝试在Google Colab中安装web3,第一步是

    !pip install web3
    

    这成功地结束了--似乎是--一个微不足道的错误

    ERROR: nbclient 0.5.1 has requirement jupyter-client>=6.1.5, but you'll have jupyter-client 5.3.5 which is incompatible.
    Installing collected packages: pycryptodome, ... jsonschema,..... eth-account, web3
      Found existing installation: jsonschema 2.6.0
        Uninstalling jsonschema-2.6.0:
          Successfully uninstalled jsonschema-2.6.0
    Successfully installed base58-2.0.1 ... jsonschema-3.2.0 ....  web3-5.13.0 websockets-8.1
    

    请注意,安装了jsonschema-3.2.0。
    现在我执行

    from web3 import Web3 
    

    并得到以下错误

    /usr/local/lib/python3.6/dist-packages/pkg_resources/__init__.py in resolve(self, requirements, env, installer, replace_conflicting, extras)
        773                 # Oops, the "best" so far conflicts with a dependency
        774                 dependent_req = required_by[req]
    --> 775                 raise VersionConflict(dist, req).with_context(dependent_req)
        776 
        777             # push the new requirements onto the stack
    
    ContextualVersionConflict: (jsonschema 2.6.0 (/usr/local/lib/python3.6/dist-packages), Requirement.parse('jsonschema<4.0.0,>=3.2.0'), {'web3'})
    

    我无法理解的是,即使安装了jsonschema-3.2.0,这个错误仍然表明,即使已卸载jsonschema 2.6.0,我们仍然坚持使用它。 请帮忙

    0 回复  |  直到 5 年前
        1
  •  4
  •   Calcutta    5 年前

    哦,好吧,我只需要重新安装jsonschema!

    !pip install --force-reinstall jsonschema==3.2.0
    

    解决了当前的问题