urllib.error.URLError: <urlopen error unknown url type: https>

Answered

I have a very simple function to pull an Excel file using Pandas from an url.  This function works perfectly in Jupyter notebook but fails in Pycharm with the following message:

C:\Users\e\AppData\Local\Continuum\anaconda3\envs\v\python.exe C:/Users/e/PycharmProjects/Blackjack/Song.py
Traceback (most recent call last):
File "C:/Users/e/PycharmProjects/Test/Song.py", line 12, in <module>
hpi_loader()
File "C:/Users/e/PycharmProjects/Test/Song.py", line 7, in hpi_loader
hpi_data = pd.read_excel(url)
File "C:\Users\e\AppData\Local\Continuum\anaconda3\envs\v\lib\site-packages\pandas\util\_decorators.py", line 188, in wrapper
return func(*args, **kwargs)
File "C:\Users\e\AppData\Local\Continuum\anaconda3\envs\v\lib\site-packages\pandas\util\_decorators.py", line 188, in wrapper
return func(*args, **kwargs)
File "C:\Users\e\AppData\Local\Continuum\anaconda3\envs\v\lib\site-packages\pandas\io\excel.py", line 350, in read_excel
io = ExcelFile(io, engine=engine)
File "C:\Users\e\AppData\Local\Continuum\anaconda3\envs\v\lib\site-packages\pandas\io\excel.py", line 653, in __init__
self._reader = self._engines[engine](self._io)
File "C:\Users\e\AppData\Local\Continuum\anaconda3\envs\v\lib\site-packages\pandas\io\excel.py", line 402, in __init__
filepath_or_buffer = _urlopen(filepath_or_buffer)
File "C:\Users\e\AppData\Local\Continuum\anaconda3\envs\v\lib\urllib\request.py", line 222, in urlopen
return opener.open(url, data, timeout)
File "C:\Users\e\AppData\Local\Continuum\anaconda3\envs\v\lib\urllib\request.py", line 531, in open
response = meth(req, response)
File "C:\Users\e\AppData\Local\Continuum\anaconda3\envs\v\lib\urllib\request.py", line 641, in http_response
'http', request, response, code, msg, hdrs)
File "C:\Users\e\AppData\Local\Continuum\anaconda3\envs\v\lib\urllib\request.py", line 563, in error
result = self._call_chain(*args)
File "C:\Users\e\AppData\Local\Continuum\anaconda3\envs\v\lib\urllib\request.py", line 503, in _call_chain
result = func(*args)
File "C:\Users\e\AppData\Local\Continuum\anaconda3\envs\v\lib\urllib\request.py", line 755, in http_error_302
return self.parent.open(new, timeout=req.timeout)
File "C:\Users\e\AppData\Local\Continuum\anaconda3\envs\v\lib\urllib\request.py", line 525, in open
response = self._open(req, data)
File "C:\Users\e\AppData\Local\Continuum\anaconda3\envs\v\lib\urllib\request.py", line 548, in _open
'unknown_open', req)
File "C:\Users\e\AppData\Local\Continuum\anaconda3\envs\v\lib\urllib\request.py", line 503, in _call_chain
result = func(*args)
File "C:\Users\e\AppData\Local\Continuum\anaconda3\envs\v\lib\urllib\request.py", line 1387, in unknown_open
raise URLError('unknown url type: %s' % type)
urllib.error.URLError: <urlopen error unknown url type: https>

Process finished with exit code 1

This is my function, any ideas?  Thanks.

import pandas as pd


def hpi_loader(
url='http://www.nationwide.co.uk/-/media/MainSite/documents/about/house-price-index/downloads/seasonal_regional.xls?date=june'):
hpi_data = pd.read_excel(url)
return hpi_data


if __name__ == "__main__":
hpi_loader()

 

 

6 comments

Hi,

Try running the following command from the command line (outside of PyCharm). Do you get the same error?

C:\Users\e\AppData\Local\Continuum\anaconda3\envs\v\python.exe C:/Users/e/PycharmProjects/Blackjack/Song.py
0

No I do not get the same error.  Seems like you know what the problem is

0

Try EAP build https://www.jetbrains.com/pycharm/nextversion/

Does it work there?

Please note, that you can have multiple PyCharm installations at the same time. So you don't need to uninstall current stable version to install EAP build.

0

Actually this is the version I have installed already.

0

It looks like the problem is a network(dns/proxy/firewall) issue and not related to PyCharm.

Could you please check them?

0

Firewall was set up correctly. When I switched to a Python 3.6 environment the issue resolved itself. I had a different issue regarding import failures that I posted about that was also resolved by going back to Python 3.6, so I think there is a general issue with Python 3.7 and Pycharm. Again as I mentioned I don’t get this error using Jupyter via Anaconda.

0

Please sign in to leave a comment.