1

Following what others suggested in: Given a big list of urls, what is a way to check which are active/inactive?

Getting the error when trying to install requests, using urllib3.

Trying to install requests.

C:\Users\yao\Desktop\My Downloads\requests-develop\requests-develop>setup.py install
Traceback (most recent call last):
  File "C:\Users\yao\Desktop\My Downloads\requests-develop\requests-develop\setup.py", line 6, in <module>
    import requests
  File "C:\Users\yao\Desktop\My Downloads\requests-develop\requests-develop\requests\__init__.py", line 52, in <module>
    from . import utils
  File "C:\Users\yao\Desktop\My Downloads\requests-develop\requests-develop\requests\utils.py", line 22, in <module>
    from .compat import parse_http_list as _parse_list_header
  File "C:\Users\yao\Desktop\My Downloads\requests-develop\requests-develop\requests\compat.py", line 95, in <module>
    from .packages import chardet
  File "C:\Users\yao\Desktop\My Downloads\requests-develop\requests-develop\requests\packages\__init__.py", line 3, in <module>
    from . import urllib3
  File "C:\Users\yao\Desktop\My Downloads\requests-develop\requests-develop\requests\packages\urllib3\__init__.py", line 16, in <module>
    from .connectionpool import (
  File "C:\Users\yao\Desktop\My Downloads\requests-develop\requests-develop\requests\packages\urllib3\connectionpool.py", line 434
    except Empty as e:
                  ^
SyntaxError: invalid syntax

Trying to use urllib3.

C:\Users\yao\Desktop\ad stuff\find urls>reqs.py
Traceback (most recent call last):
  File "C:\Users\yao\Desktop\ad stuff\find urls\reqs.py", line 1, in <module>
    import re, csv, urllib3
  File "build\bdist.win32\egg\urllib3\__init__.py", line 16, in <module>
  File "C:\Python25\lib\site-packages\urllib3-dev-py2.5.egg\urllib3\connectionpool.py", line 435
    except Empty as e:
                  ^
SyntaxError: invalid syntax

Just recently installed setuptools, pip, requests, urllib3. In that order. Did I mess up anything? Using python 2.5 btw.

Community
  • 1
  • 1
iCodeLikeImDrunk
  • 17,085
  • 35
  • 108
  • 169

1 Answers1

2

urllib3 requires Python 2.6 or greater. From their README:

  • Tested on Python 2.6+ and Python 3.2+

They dropped support for Python 2.5 in version 1.2, which was released in January 2012:

Dropped Python 2.5 support (tested on 2.6.7, 2.7.2)

Python 2.6 added a new syntax for handling exceptions, as you can read in What’s New in Python 2.6:

Alternate syntax for catching exceptions: except TypeError as exc.

urllib3 now uses this syntax, but you're trying to run it on Python 2.5 which does not support it.

Jeremy
  • 1
  • 85
  • 340
  • 366
  • weird, i have install python 2.7 as well, but it seems like everything is using python 2.5, how can i fix that? – iCodeLikeImDrunk Nov 23 '12 at 15:51
  • You seem to be using Windows. I don't, so I'm afraid I don't know the answer. On Linux/Mac OS, I would just replace every reference to `python` or `python2.5` with `python2.7`, either in the file I'm executing or the commands I'm using to execute it. – Jeremy Nov 23 '12 at 15:54