【问题标题】:module 'pip' has no attribute 'pep425tags'模块“pip”没有属性“pep425tags”
【发布时间】:2018-10-19 06:51:20
【问题描述】:

当我尝试使用 pip 安装 .whl 时

它说:

在此平台上不支持轮子

为了解决这个问题,我上网查了一下,说可以输入到shell中

进口点;打印(pip.pep425tags.get_supported())

这样我可以得到pip支持的文档和版本

但是,当我输入这些代码时,它说:

模块“pip”没有属性“pep425tags”

怎么了?

【问题讨论】:

标签: python pip python-wheel


【解决方案1】:

如果目标只是获取兼容标签列表,那么使用当前版本的 pip(例如 20.0.2):

$ path/to/pythonX.Y -m pip debug --verbose

【讨论】:

    【解决方案2】:

    这对我来说适用于 Python 2.7(在使用该版本的 virtualenv 中):

    import wheel.pep425tags
    
    print(wheel.pep425tags.get_supported())
    

    【讨论】:

      【解决方案3】:

      对于 pip v10,请使用:

      import pip._internal; print(pip._internal.pep425tags.get_supported())
      

      【讨论】:

        【解决方案4】:

        使用 Python 3.6.8 和 pip 19.1.1

        python -c "import wheel.pep425tags as w print(w.get_supported())"

        成功了!

        输出:

        [('cp36', 'cp36m', 'win_amd64'), ('cp36', 'none', 'win_amd64'), ('cp36', 'none', 'any'), ('cp3', 'none', 'any'), ('cp35', 'none', 'any'), ('cp34', 'none', 'any'), ('cp33', 'none', 'any'), ('cp32', 'none', 'any'), ('cp31', 'none', 'any'), ('cp30', 'none', 'any'), ('py3', 'none', 'win_amd64'), ('py36', 'none', 'any'), ('py3', 'none', 'any'), ('py35', 'none', 'any'), ('py34', 'none', 'any'), ('py33', 'none', 'any'), ('py32', 'none', 'any'), ('py31', 'none', 'any'), ('py30', 'none', 'any')]
        

        【讨论】:

        • 您必须发送一个必需的位置参数“archive_root”。所以 print(w.get_supported(archive_root=""))
        【解决方案5】:

        主要问题是pep425tagswheel 模块的内部事物。我相信它从来都不是这样使用的,它总是会发生变化。刚才自己面对这个问题,我注意到wheel==0.34.1pep425tagswheel==0.35.0 没有。

        所以如果你真的想使用这个模块,一定要pip3 install wheel==0.34.1

        【讨论】:

          【解决方案6】:

          一个 bash 单行,适用于 Py2.7Py3.6pip-18.1:

          python3 -c "import wheel.pep425tags as w; print(w.get_supported())" |sed -zE 's/\),/),\n/g'
          

          【讨论】:

            【解决方案7】:

            我的 GNU-Linux 机器中有几个版本的 Python,这给我带来了一些问题。 Python 2.7、3.4、3.6、...

            太乱了!我知道。 :)

            每次我使用 python3 并运行这段代码:

            import wheel.pep425tags
            print(wheel.pep425tags.get_supported())
            

            和你一样,我也遇到了这个错误:

            AttributeError: 'module' object has no attribute 'pep425tags'
            

            通过在 stackoverflow 中浏览,我注意到以下一些问题可能会对您有所帮助:

            了解您的 pip 或 pip3 设置为哪个 Python 版本很重要: 我的,pip 设置为 python 2.7pip3 也设置为 python 3.6

            首先,检查你的 pip 或 pip3 的版本:

            pip -V
            

            pip3 -V
            

            因为我使用 pip3 所以结果:

            pip 20.0.2 from /usr/local/lib/python3.6/site-packages/pip (python 3.6)
            

            这表明我的pip3使用了python3.6,这导致我直接进入了python3。 6控制台。 在这种情况下,它的工作原理和结果:

            [('cp36', 'cp36m', 'linux_x86_64'), ('cp36', 'abi3', 'linux_x86_64'), ('cp36', 'none', 'linux_x86_64'), ('cp35', 'abi3', 'linux_x86_64'), ('cp34', 'abi3', 'linux_x86_64'), ('cp36', 'none', 'any'), ('cp3', 'none', 'any'), ('cp35', 'none', 'any'), ('cp34', 'none', 'any'), ('cp33', 'none', 'any'), ...]
            

            我希望这些步骤对你有用。

            【讨论】:

              【解决方案8】:

              我也有这个问题。但是我按照以前的方法犯了一个错误。 enter image description hereTypeError: get_supported() missing 1 required positional argument: 'archive_root' ,解决方法是在get_supported()中加入参数win_amd64。

              import wheel.pep425tags as w
              print(w.get_supported("win_amd64")
              

              【讨论】:

              • 请不要只发布代码作为答案,还要解释您的代码的作用以及它如何解决问题的问题。带有解释的答案通常更有帮助,质量更高,更有可能吸引投票。
              • 感谢您的提醒。我刚刚注册并第一次尝试提出自己的解决方案。我会做得更好。
              【解决方案9】:

              试试这个,如果你有一个新版本的 pip 并且你只想要 get_supported 函数调用的结果:

              python -c "from pip._internal.utils.compatibility_tags import get_supported; print(get_supported())"
              

              【讨论】:

                【解决方案10】:

                AMD64

                import pip._internal;print(pip._internal.pep425tags.get_supported())
                

                WIN32

                import pip;print(pip.pep425tags.get_supported())
                

                然后pip install <.whl>对应平台轮(https://www.lfd.uci.edu/~gohlke/pythonlibs/)

                【讨论】:

                  猜你喜欢
                  • 2017-09-09
                  • 1970-01-01
                  • 1970-01-01
                  • 1970-01-01
                  • 1970-01-01
                  • 2017-04-27
                  • 2018-09-24
                  • 1970-01-01
                  • 2015-05-16
                  相关资源
                  最近更新 更多