Python 3 and the requests library

Ian Kelly ian.g.kelly at gmail.com
Mon Feb 9 17:42:23 EST 2015


On Mon, Feb 9, 2015 at 2:37 PM, Brian <brian.from.fl at gmail.com> wrote:
> Thank you, Ian and Zack! That was exactly the issue. Apparently, having a token.py script (one of my first Python 2 scripts to get an authorization token from a billing server) is OK for Python 2 but breaks Python 3.

Local modules that have the same absolute module path as standard
library modules will cause problems in either version of Python. I
think it's unfortunate that Python files that happen to live in the
same directory as the main script automatically get treated as
top-level modules that shadow the standard library. You're not the
first person to be confused by this.

It appears that the reason this works for you in Python 2 and not in
Python 3 is because the linecache module doesn't import tokenize in
Python 2, whereas it does in Python 3. If you had tried to import
tokenize directly in Python 2 then I expect you'd have the same
problem.



More information about the Python-list mailing list