If you use the dill package, you should be able to sort the session where pickle itself does not work.
>>> import dill as pickle >>> pickled = pickle.dumps(session) >>> restored = pickle.loads(pickled)
Get dill here: https://github.com/uqfoundation/dill
In fact, dill also makes it easy to save your python session through reboots, so you could pickle complete your entire python session as follows:
>>> pickle.dump_session('session.pkl')
Then restart python and pick up where you left off.
Python 2.7.8 (default, Jul 13 2014, 02:29:54) [GCC 4.2.1 Compatible Apple Clang 4.1 ((tags/Apple/clang-421.11.66))] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> import dill as pickle >>> pickle.load_session('session.pkl') >>> restored <requests.sessions.Session object at 0x10c012690>
source share