我的包的结构与此类似:
top/
├── __init__.py
└── io
└── __init__.py
现在我在导入标准库时遇到了这个问题urllib3.filepost
:
gonvaled@pegasus ~/top » python
Python 2.7.2 (default, Jan 11 2013, 17:58:01)
[GCC 4.4.5] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import urllib3.filepost
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/gonvaled/.virtualenvs/python2.7.2-wavilon1/lib/python2.7/site-packages/urllib3/__init__.py", line 16, in <module>
from .connectionpool import (
File "/home/gonvaled/.virtualenvs/python2.7.2-wavilon1/lib/python2.7/site-packages/urllib3/connectionpool.py", line 42, in <module>
from .request import RequestMethods
File "/home/gonvaled/.virtualenvs/python2.7.2-wavilon1/lib/python2.7/site-packages/urllib3/request.py", line 12, in <module>
from .filepost import encode_multipart_formdata
File "/home/gonvaled/.virtualenvs/python2.7.2-wavilon1/lib/python2.7/site-packages/urllib3/filepost.py", line 11, in <module>
from io import BytesIO
ImportError: cannot import name BytesIO
为什么标准库要查找top.io
?我怎样才能避免这种情况?我真的很想用top.io
我的包名。