I am facing a problem on executing simple code.
import httplib2
h = httplib2.Http(".cache")
resp, content = h.request("http://example.org/", "GET")
Output is
Traceback (most recent call last):
File "<interactive input>", line 1, in <module>
File "C:\Python27\lib\site-packages\httplib2\__init__.py", line 1175, in __init__
self.cache = FileCache(cache)
File "C:\Python27\lib\site-packages\httplib2\__init__.py", line 700, in __init__
os.makedirs(self.cache)
File "C:\Python27\lib\os.py", line 157, in makedirs
mkdir(name, mode)
WindowsError: [Error 5] Access is denied: '.cache'
Anyone with any suggestions to fix this error?
To get this working you could just leave out the cache directory:
import httplib2
h = httplib2.Http()
resp, content = h.request("http://example.org/", "GET")
As the comments say above, you don't have permission to create the .cache
directory relative to the path you're running the code from.
Of course, having a cache is better...
For a simple, in-memory cache which won't cause you permissions headaches, checkout this article I wrote: http://grahamlyons.com/article/a-simple-in-memory-cache-for-python-s-httplib2