質問: importerror:「queue」という名前のモジュールはありません requestsモジュールをインポートしようとしていますが、このエラーが発生しましたpythonバージョンはubuntu 14.04で3.4を実行しています>>> import requests traceback (most recent call last): file "/usr/local/lib/python3.4/dist-packages/requests/packages/urllib3/connectionpool.py", line 10, in <module> from queue import lifoqueue, empty, full importerror: cannot import name 'lifoqueue' during handling of the above exception, another exception occurred: traceback (most recent call last): file "<stdin>", line 1, in <module> file "/usr/local/lib/python3.4/dist-packages/requests/__init__.py", line 58, in <module> from . import utils file "/usr/local/lib/python3.4/dist-packages/requests/utils.py", line 26, in <module> from .compat import parse_http_list as _parse_list_header file "/usr/local/lib/python3.4/dist-packages/requests/compat.py", line 7, in <module> from .packages import chardet file "/usr/local/lib/python3.4/dist-packages/requests/packages/__init__.py", line 3, in <module> from . import urllib3 file "/usr/local/lib/python3.4/dist-packages/requests/packages/urllib3/__init__.py", line 10, in <module> from .connectionpool import ( file "/usr/local/lib/python3.4/dist-packages/requests/packages/urllib3/connectionpool.py", line 12, in <module> from queue import lifoqueue, empty, full importerror: no module named 'queue'
回答: import queueはlowercaseq in python 3。qをqに変更すると問題ありません。(スマートスイッチングについては、 https://stackoverflow.com/a/29688081/632951 のコードを参照してください。)