0

I'm trying to get requests working. I'm just trying line one from the documentation, here: http://docs.python-requests.org/en/master/ so I am assuming I have a bad install somehow?

Here is the example from the above:

import requests
r = requests.get('https://api.github.com/user', auth=('user', 'pass'))

I wouldn't think I'd get this kind of behavior from the first example provided in the docs.

I just get an infinite recursion from requests.get().

    File "C:\Python27\lib\requests.py", line 144, in get
        return requests.get(url, **kwargs)
      File "C:\Python27\lib\requests.py", line 144, in get
        return requests.get(url, **kwargs)
      File "C:\Python27\lib\requests.py", line 143, in get
    with ignore_insecure_warning(**kwargs):
  File "C:\Python27\lib\contextlib.py", line 17, in __enter__
    return self.gen.next()
  File "C:\Python27\lib\requests.py", line 103, in ignore_insecure_warning
    with warnings.catch_warnings():
RuntimeError: maximum recursion depth exceeded

I wonder if somehow I have python or the libraries installed incorrectly because I'm also get errors related to pip

  pip install anythingAtAll 

opens my Atom text editor with the tabs: "get-pip.py", "Install" & "anythingAtAll" but doesn't install.

If I uninstall atom, pip works fine. I haven't seen these behaviors on other machines. I tried a fresh install of python & atom that didn't resolve the pip errors.

DaveP
  • 259
  • 4
  • 16

1 Answers1

1

You have a different module named requests.py. It is calling itself repeatedly:

  File "C:\Python27\lib\requests.py", line 144, in get
    return requests.get(url, **kwargs)
  File "C:\Python27\lib\requests.py", line 144, in get
    return requests.get(url, **kwargs)

That's the get() function calling itself, eventually hitting the recursion limit with the context manager on the line before it.

Rename or delete that file, it is masking the real requests library (which uses a package, not a single module, so you'll see requests/<something>.py names in a traceback.

Martijn Pieters
  • 1,048,767
  • 296
  • 4,058
  • 3,343
  • Yep, I reinstalled (again) and the superfluous requests.py was removed. I may have accidentally install 2.7.0 rather than 2.7.14. I'm not sure if 2.7.0 comes with requests? Or if that was installed separately. Thanks Martijn. – DaveP Dec 07 '17 at 21:39
  • @DaveP: 2.7.0 does not come with a `requests.py` file, not in `lib`. See https://github.com/python/cpython/tree/v2.7/Lib – Martijn Pieters Dec 08 '17 at 07:46