I am using Mac OSX 10.10.5, and Python version 3.5.2, and IDLE version 3.5.2.
I am extremely new to Python, and am trying to use the urllib3 module in IDLE. I have used the following code in the Terminal with success (the number 200 is returned):
import urllib3
http = urllib3.PoolManager()
r = http.request('GET', 'http://httpbin.org/robots.txt')
r.status
But the same code does not work in IDLE. In IDLE I get the following error:
Traceback (most recent call last):
File "/Users/faculty/Documents/Python/Scraping_v1_d1.py", line 1, in <module>
import urllib3
ImportError: No module named 'urllib3'
I have also attempted to use other code such as the following in IDLE:
import urllib3
htmlfile = urllib3.urlopen("http://google.com")
htmltext = htmlfile.read()
print (htmltext)
But I get the same error.
In my site-packages folder I have these pip and urllib3 folders:
1) pip
2) pip-9.0.1.dist-info
3) urllib3
4) urllib3-1.19.dist-info
I found one source that suggested that I try to do the following:
import sys
sys.version
sys.path
This is the response in Terminal:
import sys sys.version '2.7.10 (default, Jul 14 2015, 19:46:27) \n[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.39)]' sys.path ['', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python27.zip', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-darwin', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac/lib-scriptpackages', '/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-old', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload', '/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/PyObjC', '/Library/Python/2.7/site-packages']
When I type the same code into IDLE, nothing happens (this is all I get):
========= RESTART: /Users/faculty/Documents/Python/Scraping_v1_d1.py =========
I have searched the web and stackoverflow.com extensively, but can't locate a solution. Does anyone have any insight?
Thanks!