简体   繁体   中英

Import error for urllib3

I'm using Python 2.7 and am trying pull data from an API using a python script and urllib3. I've installed urllib3 by copying the source code but from GitHub. But, I'm still getting the following error when running the script:

ImportError: No module named urllib3

The script starts simply enough with:

import urllib3 
http = urllib3.PoolManager() 

I've checked the urllib3 file, and it includes the util file cited in other responses

I've installed urllib3 by copying the source code but from GitHub.

Bad way to "install" urllib3 . Use this instead

pip install urllib3

you need to copy that module directory ( urllib3/urllib3/ ). you'll find __init__py file on that directory to that script's directory.

Another way:

$ pip search urllib3
opbeat_python_urllib3 (1.1)  - An urllib3 transport for Opbeat
apiclient (1.0.3)            - Framework for making good API client libraries using urllib3.
urllib3 (1.17)               - HTTP library with thread-safe connection pooling, file post,
                               and more.
httplib2shim (0.0.1)         - A wrapper over urllib3 that matches httplib2's interface
yieldfrom.urllib3 (0.1.4)    - Asyncio HTTP library with thread-safe connection pooling, file
                               post, and more.
urllib3-mock (0.3.3)         - A utility library for mocking out the `urllib3` Python
                               library.

Installing it using pip

pip install urllib3

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM