Python 3 and the requests library

Zachary Ware zachary.ware+pylist at gmail.com
Mon Feb 9 16:03:33 EST 2015


On Mon, Feb 9, 2015 at 2:37 PM, Brian <brian.from.fl at gmail.com> wrote:
> Zach,
>
> Here is what I get on the Mac:
>
> $ python3 -c "import token;print(token.__file__)"
> /Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/token.py

That looks correct.

> Just for grins, I also ran it against the built-in Python 2.7.5 version:
>
> $ python -c "import token;print(token.__file__)"
> /System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/token.pyc
>
> The only difference seems to be that the 2.7.5 version has precompiled it.

The 3.4 version is also precompiled, but __file__ gives the filename
of the actual module (not the .pyc implementation detail).  You can
find precompiled token.py for 3.4 at
/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/__pycache__/token.cpython-34.pyc

> Then I followed your example but ran it against the logging module instead, as that
> seems to be where the problem lies.

Not so, the traceback you posted shows pretty clearly that the problem
is in the tokenize module, where the token module it has imported does
not have an __all__ attribute.

> Again, for both version (broken 3 and working 2) as a comparison:
>
> $ python3 -c "import logging;print(logging.__file__)"
> /Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/logging/__init__.py

This should have failed with the same traceback as your test2.py.

> $ python -c "import logging;print(logging.__file__)"
> /System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/logging/__init__.pyc
>
> But nothing is pointing to anything except what appears to be the formally installed
> versions of these library modules.

Try your test again.  If it fails again, run my test again at the same prompt.

-- 
Zach



More information about the Python-list mailing list