簡體   English   中英

無法在 Python 3 上安裝 wsgiref

[英]Failed to install wsgiref on Python 3

我在安裝wsgiref遇到問題:

$ python --version
Python 3.6.0 :: Anaconda 4.3.1 (x86_64)
$ pip --version
pip 9.0.1 from /anaconda/lib/python3.6/site-packages (python 3.6)

我的requirement.txt文件如下所示。

numpy==1.8.1
scipy==0.14.0
pyzmq==14.3.1
pandas==0.14.0
Jinja2==2.7.3
MarkupSafe==0.23
backports.ssl-match-hostname==3.4.0.2
gnureadline==6.3.3
ipython==2.1.0
matplotlib==1.3.1
nose==1.3.3
openpyxl==1.8.6
patsy==0.2.1
pyparsing==2.0.2
python-dateutil==2.2
pytz==2014.4
scikit-learn==0.14.1
six==1.7.3
tornado==3.2.2
wsgiref==0.1.2
statsmodels==0.5.0

當我運行pip install -r requirement.txt ,出現此錯誤

Collecting wsgiref==0.1.2 (from -r requirements.txt (line 20))
  Using cached wsgiref-0.1.2.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/xs/y0pbzxkn7gqcdtrz4cpxtwrw0000gn/T/pip-build-hkiqbu1j/wsgiref/setup.py", line 5, in <module>
        import ez_setup
      File "/private/var/folders/xs/y0pbzxkn7gqcdtrz4cpxtwrw0000gn/T/pip-build-hkiqbu1j/wsgiref/ez_setup/__init__.py", line 170
        print "Setuptools version",version,"or greater has been installed."
                                 ^
    SyntaxError: Missing parentheses in call to 'print'
    
    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /private/var/folders/xs/y0pbzxkn7gqcdtrz4cpxtwrw0000gn/T/pip-build-hkiqbu1j/wsgiref/

我試圖運行pip install --upgrade setuptoolssudo easy_install -U setuptools但都sudo easy_install -U setuptools 我怎么解決這個問題?

wsgiref 已經作為標准庫包含在 Python 3 中......所以,如果您嘗試使用 Python 3,請繼續導入 wsgiref,就是這樣。

根據這一行SyntaxError: Missing parentheses in call to 'print' ,我認為它需要 Python 2.x 來運行setup.py 是否在print使用括號是 Python 2 和 Python 3 的不同語法。

這是Github 問題的解決方案:

有一些修復可以讓您運行,按照最少的工作到最多的順序:

  1. 切換到 python2.7 進行安裝。

  2. 嘗試使用 pip install --upgrade wsgiref 升級 wsgiref,並查看最新版本是否適用於您的設置,並使用 will(如果沒有,您會注意到 http/webhooks 的東西不起作用。

  3. 如果您嘗試 2) 並且它有效,請在此處提交 PR,並在 requirements.txt 中使用升級版本。 (您可以使用 pip freeze 找出您擁有的版本)。

您可以在此處找到有關語法差異的更多信息

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM