我有一个小的python(2.7)脚本,适用于多个线程。其中一个线程将读取全局列表,并为此列表的每个条目发布https发布请求。
为此,我看到最好的方法是使用python请求模块。我用pip安装它(没问题,它放在... Python / 2.7 / site-packages / requests / ...),但是,当我在我的脚本中导入这个模块时,我收到一个错误。
我创建了另一个只有一行(导入请求)的脚本来重现错误,我明白了:
Traceback (most recent call last):
File "req.py", line 1, in <module>
import requests
File "/Library/Python/2.7/site-packages/requests/__init__.py", line 43, in <module>
import urllib3
File "/Library/Python/2.7/site-packages/urllib3/__init__.py", line 8, in <module>
from .connectionpool import (
File "/Library/Python/2.7/site-packages/urllib3/connectionpool.py", line 11, in <module>
from .exceptions import (
File "/Library/Python/2.7/site-packages/urllib3/exceptions.py", line 2, in <module>
from .packages.six.moves.http_client import (
File "/Library/Python/2.7/site-packages/urllib3/packages/six.py", line 203, in load_module
mod = mod._resolve()
File "/Library/Python/2.7/site-packages/urllib3/packages/six.py", line 115, in _resolve
return _import_module(self.mod)
File "/Library/Python/2.7/site-packages/urllib3/packages/six.py", line 82, in _import_module
__import__(name)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.py", line 69, in <module>
from array import array
File "/Users/carlestalenssebastia/Documents/mychip/raspberry pi/array.py", line 3, in <module>
IndexError: list index out of range
Python 2.7.10 MacBook Pro与macOS Sierra(v 10.12)
我做错了吗?我没有以正确的方式安装模块吗?