首页 > 解决方案 > 我无法在 ubuntu 中安装 wsgiref

问题描述

我无法在 ubuntu 中安装 wsgiref,我尝试使用 pip 安装它。

pip3 install wsgiref
Defaulting to user installation because normal site-packages is not writeable
Collecting wsgiref
  Using cached wsgiref-0.1.2.zip (37 kB)
    ERROR: Command errored out with exit status 1:
     command: /usr/bin/python3 -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-8_gcoo21/wsgiref_7a9633f256d6441e8608f2e540e51c18/setup.py'"'"'; __file__='"'"'/tmp/pip-install-8_gcoo21/wsgiref_7a9633f256d6441e8608f2e540e51c18/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /tmp/pip-pip-egg-info-bmlvfwrd
         cwd: /tmp/pip-install-8_gcoo21/wsgiref_7a9633f256d6441e8608f2e540e51c18/
    Complete output (8 lines):
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmp/pip-install-8_gcoo21/wsgiref_7a9633f256d6441e8608f2e540e51c18/setup.py", line 5, in <module>
        import ez_setup
      File "/tmp/pip-install-8_gcoo21/wsgiref_7a9633f256d6441e8608f2e540e51c18/ez_setup/__init__.py", line 170
        print "Setuptools version",version,"or greater has been installed."
              ^
    SyntaxError: Missing parentheses in call to 'print'. Did you mean print("Setuptools version",version,"or greater has been installed.")?
    ----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.```

标签: pythonpip

解决方案


wsgiref 不支持你的 Python 版本

您必须使用 Python 2 和 Pip 3,有关更多信息,请阅读

“这是 wsgiref 库的独立版本,它为 Python 版本 < 3.2 的 WSGI 1.0.1 (PEP 3333) 提供验证支持,并包括新的 wsgiref.util.test() 实用程序函数。”

这是Github问题的解决方案:

有一些修复可以让你运行,按照最少的工作到大多数:

  1. 切换到 python2.7 进行安装。

  2. 尝试使用 pip install --upgrade wsgiref 升级 wsgiref,并查看最新版本是否适用于您的设置,以及是否适用(如果不适用,您会注意到 http/webhooks 的东西不起作用。

  3. 如果您尝试 2) 并且有效,请在此处提交 PR,并在 requirements.txt 中使用升级版本。(您可以使用 pip freeze 找出您拥有的版本)。


推荐阅读