toone14
toone14

Reputation: 3

Python requests module suddenly stopped working

I am new to python and I have imported a couple modules for a script I am working on and one of them is requests. After a couple of weeks testing my script with no issues all of sudden in stop working and the message below appears.

I manually installed requests and didn't install any other module. The last thing I did is do some import command on the python shell to test if it is available.

[a.panaglima]$ ./downloader_test.py
Traceback (most recent call last):
  File "./downloader_test.py", line 2, in <module>
    import time, datetime, requests, base64, urllib2, urllib, json
  File "/home/SRL/a.panaglima/time.py", line 2, in <module>
    import time, datetime, requests, base64, urllib2, urllib, json
  File "/usr/lib/python2.6/site-packages/requests-2.5.3-py2.6.egg/requests/__init__.py", line 53, in <module>
    from .packages.urllib3.contrib import pyopenssl
  File "/usr/lib/python2.6/site-packages/requests-2.5.3-py2.6.egg/requests/packages/__init__.py", line 63, in load_module
    __import__(name)
  File "/usr/lib/python2.6/site-packages/requests-2.5.3-py2.6.egg/requests/packages/urllib3/__init__.py", line 10, in <module>
    from .connectionpool import (
  File "/usr/lib/python2.6/site-packages/requests-2.5.3-py2.6.egg/requests/packages/urllib3/connectionpool.py", line 2, in <module>
    import logging
  File "/usr/lib64/python2.6/logging/__init__.py", line 89, in <module>
    _startTime = time.time()

Upvotes: 0

Views: 1508

Answers (1)

jedwards
jedwards

Reputation: 30210

It looks like you have a file time.py (/home/SRL/a.panaglima/time.py) that is causing issues shadowing the built-in time module.

Remove/rename this file.

Alternatively, refactor your project and use from __future__ import absolute_import at the top of your file (above other imports). This became standard in 2.7 Python3

Upvotes: 1

Related Questions