14

I have a problem installing 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)

My requirement.txt file are shown as below.

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

when I run pip install -r requirement.txt, I got this error

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/

I have tried to run pip install --upgrade setuptools and sudo easy_install -U setuptools but neither works. How can I solve this problem?

snakecharmerb
  • 47,570
  • 11
  • 100
  • 153
Joey Yi Zhao
  • 37,514
  • 71
  • 268
  • 523

3 Answers3

30

wsgiref is already been included as a standard library in Python 3... So in case if you are trying with Python 3 just go ahead and import wsgiref thats it.

Aneesh Damodaran
  • 566
  • 4
  • 10
4

According to this line SyntaxError: Missing parentheses in call to 'print', I think it needs Python 2.x to run the setup.py. Whether to use parentheses in print is the different syntax of Python 2 and Python 3.

This is the solution from the Github issue:

There are a few fixes that will get you running, in order of least work to most:

  1. Switch over to python2.7 for your will installs.

  2. Try to upgrade wsgiref with pip install --upgrade wsgiref, and see if the latest version works with your setup, and with will (if it doesn't, you'd notice the http/webhooks stuff not working.

  3. If you try 2) and it works, submit a PR here with the upgraded version in requirements.txt. (You can find out what versions you've got by using pip freeze).

You can find more about the syntax difference here

Community
  • 1
  • 1
Jiahao Cai
  • 1,222
  • 1
  • 11
  • 25
  • 2
    Remove dependency, use python3's `wsgiref` [correct answer](https://stackoverflow.com/a/49874665/3202958) – Nrzonline Oct 30 '19 at 16:06
0

Solution: Flask-restful is deprecated, use version flask-restx

  • 1
    Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Dec 05 '22 at 19:12