Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialJason Anders
Treehouse Moderator 145,860 Points[SOLVED] Any ideas on why I'm getting this error and failure to compile?
Well, only the third video... and I broke it. :(
Any ideas?
/Users/ja/PycharmProjects/web_scraping/venv/bin/python /Users/ja/PycharmProjects/web_scraping/scraper.py
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/urllib/request.py", line 1240, in do_open
h.request(req.get_method(), req.selector, req.data, headers)
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/http/client.py", line 1083, in request
self._send_request(method, url, body, headers)
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/http/client.py", line 1128, in _send_request
self.endheaders(body)
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/http/client.py", line 1079, in endheaders
self._send_output(message_body)
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/http/client.py", line 911, in _send_output
self.send(msg)
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/http/client.py", line 854, in send
self.connect()
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/http/client.py", line 1237, in connect
server_hostname=server_hostname)
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/ssl.py", line 376, in wrap_socket
_context=self)
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/ssl.py", line 747, in __init__
self.do_handshake()
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/ssl.py", line 983, in do_handshake
self._sslobj.do_handshake()
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/ssl.py", line 628, in do_handshake
self._sslobj.do_handshake()
ssl.SSLError: [SSL: TLSV1_ALERT_PROTOCOL_VERSION] tlsv1 alert protocol version (_ssl.c:645)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Users/ja/PycharmProjects/web_scraping/scraper.py", line 4, in <module>
html = urlopen('https://treehouse-projects.github.io/horse-land/index.html')
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/urllib/request.py", line 162, in urlopen
return opener.open(url, data, timeout)
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/urllib/request.py", line 465, in open
response = self._open(req, data)
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/urllib/request.py", line 483, in _open
'_open', req)
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/urllib/request.py", line 443, in _call_chain
result = func(*args)
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/urllib/request.py", line 1283, in https_open
context=self._context, check_hostname=self._check_hostname)
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/urllib/request.py", line 1242, in do_open
raise URLError(err)
urllib.error.URLError: <urlopen error [SSL: TLSV1_ALERT_PROTOCOL_VERSION] tlsv1 alert protocol version (_ssl.c:645)>
Process finished with exit code 1
I'm still relatively new to Python and PyCharm, so I'm kind of at a loss now for troubleshooting.
Thanks in advance!
5 Answers
Jason Anders
Treehouse Moderator 145,860 PointsWell,
After banging my head against the wall a few times, I finally noticed that PyCharm interpreter was, for reasons I'm not sure, using Python 3.5.1
. This version will throw that error because of the deprecated use by Apple of OpenSSL
.
This is, however, now included in the latest version of Python (3.7) and is why the code runs once this was changed.
I am running on a Mac
Once I went to the Applications and found the Python 3.7 folder, I just double-clicked the Update Shell Command
file and like magic, everything now seems to work just like Ken's
I need a Tylenol now! Lol
Hope this helps someone else down the road! :)
Mirza Gogic
4,342 PointsOn your Mac, if you're using it, go to Applications, Python 3.7 and then double-click "Install Certificates.command". That should do it.
P.S. Don't forget to install a parser. For some reason, hmtl-parser didn't work for me, so I used "lxml" instead. Worked like a charm.
Ross Coe
5,061 Pointschanging the interpreter only worked temporarily - these commands worked https://timonweb.com/tutorials/fixing-certificate_verify_failed-error-when-trying-requests_html-out-on-mac/
Mischa Yartsev
20,562 PointsNice man, that link really helped
olu adesina
23,007 Pointsaaaaahhh, I see, Thank you!
Ross Coe
5,061 PointsI had this but changed the projects interpretor to be the system one (maybe there was python3 and update command in venv?) https://www.jetbrains.com/help/pycharm-edu/configuring-available-python-interpreters.html
olu adesina
23,007 Pointsolu adesina
23,007 PointsI don't know where I am going, I cannot find the Update Shell Command - I am currently using a Mac - could you explain where you went exactly?
Jason Anders
Treehouse Moderator 145,860 PointsJason Anders
Treehouse Moderator 145,860 Pointsolu adesina
Once you download Python 3.7, there should be a "Python 3.7" folder in your Root Application folder in Finder. Inside that folder there is the
Update Shell Command
command file that you just double click on.