unable to download spacy model - python-3.x

Downloading spacy "en" model by following command
python -m spacy download en
throws URL error.
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/runpy.py", line 85, in _run_code
exec(code, run_globals)
File "/Users/siddharthdas/venvs/chai/lib/python3.6/site-packages/spacy/__main__.py", line 31, in <module>
plac.call(commands[command], sys.argv[1:])
File "/Users/siddharthdas/venvs/chai/lib/python3.6/site-packages/plac_core.py", line 328, in call
cmd, result = parser.consume(arglist)
File "/Users/siddharthdas/venvs/chai/lib/python3.6/site-packages/plac_core.py", line 207, in consume
return cmd, self.func(*(args + varargs + extraopts), **kwargs)
File "/Users/siddharthdas/venvs/chai/lib/python3.6/site-packages/spacy/cli/download.py", line 30, in download
shortcuts = get_json(about.__shortcuts__, "available shortcuts")
File "/Users/siddharthdas/venvs/chai/lib/python3.6/site-packages/spacy/cli/download.py", line 55, in get_json
data = url_read(url)
File "/Users/siddharthdas/venvs/chai/lib/python3.6/site-packages/spacy/compat.py", line 82, in url_read
file_ = url_open(url)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/urllib/request.py", line 223, in urlopen
return opener.open(url, data, timeout)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/urllib/request.py", line 526, in open
response = self._open(req, data)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/urllib/request.py", line 544, in _open
'_open', req)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/urllib/request.py", line 504, in _call_chain
result = func(*args)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/urllib/request.py", line 1361, in https_open
context=self._context, check_hostname=self._check_hostname)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/urllib/request.py", line 1320, in do_open
raise URLError(err)
urllib.error.URLError: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:749)>
Then I tried installing Install Certificates.command but it didn't solved the problem.
Specifications:
OS: Mac High Sierra
ENV: venv (python virtual environment)

The problem might be related to this issue and PR, and the fact that unlike requests, urllib doesn't check for certificates in extra places.
After some back and forth, the upcoming version of spaCy will revert this change and go back to using requests – dropping the dependency just wasn't worth the hassle. In the meantime, you can always download and install the models manually by pointing pip install to the direct URL. See this section in the docs for details.

Related

pip3 package installation fails with *ReadTimeoutError* regardless of default-timeout setting

The problem
On a fresh and minimal Ubuntu 20.04 installation with ufw inactive:
pip3 fails with HTTPSConnectionPool timeout.
pip3 fails to install or update any package in a freshly installed OS.
pip3 fails with the same error when installing local wheel files.
pip3 fails in both a virtual python environment and at the system-level environment.
Environment
Ubuntu 20.04 LTS
fresh install,
apt updated/upgraded
Python 3.8
Additional details
--default-timeout=100
--default-timeout=1000
UPDATE:
Traceback after user-interrupt python -m pip install -U pip
^CERROR: Operation cancelled by user
^CTraceback (most recent call last):
File "/usr/lib/python3.8/runpy.py", line 194, in _run_module_as_main
return _run_code(code, main_globals, None,
File "/usr/lib/python3.8/runpy.py", line 87, in _run_code
exec(code, run_globals)
File "/home/zippy/Documents/python_workspace/py_virt_env/lib/python3.8/site-packages/pip/__main__.py", line 26, in <module>
sys.exit(_main())
File "/home/zippy/Documents/python_workspace/py_virt_env/lib/python3.8/site-packages/pip/_internal/cli/main.py", line 75, in main
return command.main(cmd_args)
File "/home/zippy/Documents/python_workspace/py_virt_env/lib/python3.8/site-packages/pip/_internal/cli/base_command.py", line 114, in main
return self._main(args)
File "/home/zippy/Documents/python_workspace/py_virt_env/lib/python3.8/site-packages/pip/_internal/cli/base_command.py", line 226, in _main
self.handle_pip_version_check(options)
File "/home/zippy/Documents/python_workspace/py_virt_env/lib/python3.8/site-packages/pip/_internal/cli/req_command.py", line 158, in handle_pip_version_check
pip_self_version_check(session, options)
File "/home/zippy/Documents/python_workspace/py_virt_env/lib/python3.8/site-packages/pip/_internal/self_outdated_check.py", line 207, in pip_self_version_check
best_candidate = finder.find_best_candidate("pip").best_candidate
File "/home/zippy/Documents/python_workspace/py_virt_env/lib/python3.8/site-packages/pip/_internal/index/package_finder.py", line 883, in find_best_candidate
candidates = self.find_all_candidates(project_name)
File "/home/zippy/Documents/python_workspace/py_virt_env/lib/python3.8/site-packages/pip/_internal/index/package_finder.py", line 827, in find_all_candidates
package_links = self.process_project_url(
File "/home/zippy/Documents/python_workspace/py_virt_env/lib/python3.8/site-packages/pip/_internal/index/package_finder.py", line 792, in process_project_url
html_page = self._link_collector.fetch_page(project_url)
File "/home/zippy/Documents/python_workspace/py_virt_env/lib/python3.8/site-packages/pip/_internal/index/collector.py", line 612, in fetch_page
return _get_html_page(location, session=self.session)
File "/home/zippy/Documents/python_workspace/py_virt_env/lib/python3.8/site-packages/pip/_internal/index/collector.py", line 451, in _get_html_page
resp = _get_html_response(url, session=session)
File "/home/zippy/Documents/python_workspace/py_virt_env/lib/python3.8/site-packages/pip/_internal/index/collector.py", line 149, in _get_html_response
resp = session.get(
File "/home/zippy/Documents/python_workspace/py_virt_env/lib/python3.8/site-packages/pip/_vendor/requests/sessions.py", line 543, in get
return self.request('GET', url, **kwargs)
File "/home/zippy/Documents/python_workspace/py_virt_env/lib/python3.8/site-packages/pip/_internal/network/session.py", line 421, in request
return super(PipSession, self).request(method, url, *args, **kwargs)
File "/home/zippy/Documents/python_workspace/py_virt_env/lib/python3.8/site-packages/pip/_vendor/requests/sessions.py", line 530, in request
resp = self.send(prep, **send_kwargs)
File "/home/zippy/Documents/python_workspace/py_virt_env/lib/python3.8/site-packages/pip/_vendor/requests/sessions.py", line 643, in send
r = adapter.send(request, **kwargs)
File "/home/zippy/Documents/python_workspace/py_virt_env/lib/python3.8/site-packages/pip/_vendor/cachecontrol/adapter.py", line 53, in send
resp = super(CacheControlAdapter, self).send(request, **kw)
File "/home/zippy/Documents/python_workspace/py_virt_env/lib/python3.8/site-packages/pip/_vendor/requests/adapters.py", line 439, in send
resp = conn.urlopen(
File "/home/zippy/Documents/python_workspace/py_virt_env/lib/python3.8/site-packages/pip/_vendor/urllib3/connectionpool.py", line 665, in urlopen
httplib_response = self._make_request(
File "/home/zippy/Documents/python_workspace/py_virt_env/lib/python3.8/site-packages/pip/_vendor/urllib3/connectionpool.py", line 376, in _make_request
self._validate_conn(conn)
File "/home/zippy/Documents/python_workspace/py_virt_env/lib/python3.8/site-packages/pip/_vendor/urllib3/connectionpool.py", line 994, in _validate_conn
conn.connect()
File "/home/zippy/Documents/python_workspace/py_virt_env/lib/python3.8/site-packages/pip/_vendor/urllib3/connection.py", line 352, in connect
self.sock = ssl_wrap_socket(
File "/home/zippy/Documents/python_workspace/py_virt_env/lib/python3.8/site-packages/pip/_vendor/urllib3/util/ssl_.py", line 370, in ssl_wrap_socket
return context.wrap_socket(sock, server_hostname=server_hostname)
File "/usr/lib/python3.8/ssl.py", line 500, in wrap_socket
return self.sslsocket_class._create(
File "/usr/lib/python3.8/ssl.py", line 1040, in _create
self.do_handshake()
File "/usr/lib/python3.8/ssl.py", line 1309, in do_handshake
self._sslobj.do_handshake()
KeyboardInterrupt
UPDATE
Sanity check - OK
laptop082:468$ curl https://pypi.org:443/simple/pip/
<!DOCTYPE html>
<html>
<head>
<meta name="pypi:repository-version" content="1.0">
<title>Links for pip</title>
</head>
<body>
<h1>Links for pip</h1>
pip-0.2.tar.gz<br/>
.
.
.
Questions
What are my options?
Will a Ubuntu re-install be necessary?
UPDATE:
Re-installation of Ubuntu 20.04 did not resolve the problem.
Please advise.

Python 3.7 - Download Image - Urllib.request.urlretrieve Error

I am really new to programming and currently learning python on Youtube ('The New Boston - Python 3' )
Was trying to download an image from internet based on the code show in the video but an error pop up.
Here is the code :
import random
import urllib.request
def download_web_image(url):
name = random.randrange(1,1000)
full_name = str(name) + '.gif' #str convert number to word
urllib.request.urlretrieve(url, full_name)
download_web_image ('https://images.freeimages.com/images/large-previews/ed3/a-stormy-paradise-1-1563744.jpg')
And the error:
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/urllib/request.py", line 1317, in do_open
encode_chunked=req.has_header('Transfer-encoding'))
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/http/client.py", line 1229, in request
self._send_request(method, url, body, headers, encode_chunked)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/http/client.py", line 1275, in _send_request
self.endheaders(body, encode_chunked=encode_chunked)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/http/client.py", line 1224, in endheaders
self._send_output(message_body, encode_chunked=encode_chunked)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/http/client.py", line 1016, in _send_output
self.send(msg)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/http/client.py", line 956, in send
self.connect()
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/http/client.py", line 1392, in connect
server_hostname=server_hostname)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/ssl.py", line 412, in wrap_socket
session=session
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/ssl.py", line 853, in _create
self.do_handshake()
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/ssl.py", line 1117, in do_handshake
self._sslobj.do_handshake()
ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self signed certificate in certificate chain (_ssl.c:1056)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Users/isaactai/PycharmProjects/isaacfirst/IMAGEDOWNLOAD.py", line 10, in
download_web_image ('https://images.freeimages.com/images/large-previews/ed3/a-stormy-paradise-1-1563744.jpg')
File "/Users/isaactai/PycharmProjects/isaacfirst/IMAGEDOWNLOAD.py", line 8, in download_web_image
urllib.request.urlretrieve(url, full_name)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/urllib/request.py", line 247, in urlretrieve
with contextlib.closing(urlopen(url, data)) as fp:
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/urllib/request.py", line 222, in urlopen
return opener.open(url, data, timeout)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/urllib/request.py", line 525, in open
response = self._open(req, data)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/urllib/request.py", line 543, in _open
'_open', req)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/urllib/request.py", line 503, in _call_chain
result = func(*args)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/urllib/request.py", line 1360, in https_open
context=self._context, check_hostname=self._check_hostname)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/urllib/request.py", line 1319, in do_open
raise URLError(err)
urllib.error.URLError:
Process finished with exit code 1
I am using PyCharm 2018.3 version
Please help me, thank you
Go to the folder where Python is installed. It should have a name like Python 3.x with x being whatever version of python you installed. Now double click on 'Install Certificates.command'. Had this error before and someone on stack helped me fix it also.
The path for me was as follows:
C:\Python33\Tools\Scripts
If that doesn't work here is another workaround using the ssl package:
pip install ssl
Do this before running the code. Then add this to your code.
import ssl
ssl._create_default_https_context = ssl._create_unverified_context
Essentially what this does is make your request "secure" so the HTTPS site will actually accept the request coming from python. You should always do this before trying to access a site with the https prefix.

CERTIFICATE_VERIFY_FAILED Python 3.6 mac osx can't fix with 'Install Certificates.command'

I am aware of the update in Python 3.6 where you need to run the 'Install Certificates.command' in order to get SSL working again, however it doesn't seem to work for me.
Running the file results in:
-- pip install --upgrade certifi
Requirement already up-to-date: certifi in /Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages (2018.4.16)
-- removing any existing file or link
-- creating symlink to certifi certificate bundle
-- setting permissions
-- update complete
And I've also explicitly run
pip3 install certifi
Requirement already satisfied: certifi in /Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages (2018.4.16)
Yet when I try to run my application (using suds-py3) I get the following:
Traceback (most recent call last):
File "./get_docs.py", line 38, in <module>
session = Client(url_SessionWebService)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/suds/client.py", line 111, in __init__
self.wsdl = reader.open(url)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/suds/reader.py", line 151, in open
d = self.fn(url, self.options)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/suds/wsdl.py", line 135, in __init__
d = reader.open(url)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/suds/reader.py", line 78, in open
d = self.download(url)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/suds/reader.py", line 94, in download
fp = self.options.transport.open(Request(url))
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/suds/transport/http.py", line 174, in open
return HttpTransport.open(self, request)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/suds/transport/http.py", line 63, in open
return self.u2open(u2request)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/suds/transport/http.py", line 119, in u2open
return url.open(u2request, timeout=tm)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/urllib/request.py", line 532, in open
response = meth(req, response)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/urllib/request.py", line 642, in http_response
'http', request, response, code, msg, hdrs)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/urllib/request.py", line 564, in error
result = self._call_chain(*args)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/urllib/request.py", line 504, in _call_chain
result = func(*args)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/urllib/request.py", line 756, in http_error_302
return self.parent.open(new, timeout=req.timeout)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/urllib/request.py", line 526, in open
response = self._open(req, data)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/urllib/request.py", line 544, in _open
'_open', req)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/urllib/request.py", line 504, in _call_chain
result = func(*args)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/urllib/request.py", line 1361, in https_open
context=self._context, check_hostname=self._check_hostname)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/urllib/request.py", line 1320, in do_open
raise URLError(err)
urllib.error.URLError: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:833)>
I've also tried adding the following to bypass:
import ssl
ssl._create_default_https_context = ssl._create_unverified_context
But the resulting call seems to indicate that the request was not authenticated
Any suggestions on how to further debug this?
I have just solved the problem in my side:
to install certifi do this:
python3 -m pip install --upgrade certifi --trusted-host pypi.org --trusted-host files.pythonhosted.org
You just copy and paste that command in your Mac terminal or any IDE terminal such as Visual Studio code.

SSL: CERTIFICATE_VERIFY_FAILED with urllib

I'm running into trouble with the module urllib (Python 3.6). Every time I use the module, I get a page's worth of errors.
what's wrong with urllib and how to fix it?
import urllib.request
url='https://www.goodreads.com/quotes/tag/artificial-intelligence'
u1 = urllib.request.urlopen(url)
print(u1)
That block of code likes to spit out this mouthful of stuff:
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/urllib/request.py", line 1318, in do_open
encode_chunked=req.has_header('Transfer-encoding'))
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/http/client.py", line 1239, in request
self._send_request(method, url, body, headers, encode_chunked)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/http/client.py", line 1285, in _send_request
self.endheaders(body, encode_chunked=encode_chunked)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/http/client.py", line 1234, in endheaders
self._send_output(message_body, encode_chunked=encode_chunked)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/http/client.py", line 1026, in _send_output
self.send(msg)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/http/client.py", line 964, in send
self.connect()
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/http/client.py", line 1400, in connect
server_hostname=server_hostname)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/ssl.py", line 407, in wrap_socket
_context=self, _session=session)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/ssl.py", line 814, in __init__
self.do_handshake()
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/ssl.py", line 1068, in do_handshake
self._sslobj.do_handshake()
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/ssl.py", line 689, in do_handshake
self._sslobj.do_handshake()
ssl.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:777)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Users/a-nguyen/Downloads/EzSorses/APAsauce.py", line 3, in <module>
u1 = urllib.request.urlopen(url)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/urllib/request.py", line 223, in urlopen
return opener.open(url, data, timeout)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/urllib/request.py", line 526, in open
response = self._open(req, data)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/urllib/request.py", line 544, in _open
'_open', req)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/urllib/request.py", line 504, in _call_chain
result = func(*args)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/urllib/request.py", line 1361, in https_open
context=self._context, check_hostname=self._check_hostname)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/urllib/request.py", line 1320, in do_open
raise URLError(err)
urllib.error.URLError: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:777)>
Seems like something's off with the module itself.
There is command line program that you can run on MacOsX that will install the certificates:
sudo /Applications/Python\ 3.6/Install\ Certificates.command
The sudo command will prompt for you password to elevate your privileges.
a dirty (not safe in terms of security) but fast hack like this do the job for me:
import ssl
ssl._create_default_https_context = ssl._create_unverified_context
I had the same issue. My python version is 3.6.5 and I'm on Mac OSX. When I tried to connect to the HTTPS sites I started getting the
<urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:833)>
exception. So, it was so obvious to me that the python on my machine has no certificates. I just ran the file from the path /Applications/Python 3.6 with a file name Install Certificates.command. This solved my issue.
I reffered to this post.
To fix the problem, open your bash and write:
cd /Applications/Python 3.6
then:
sudo Certificates.command

Python - How to open urls (html files) which are located on an internal network with urlopen?

The addresses I am trying to open look like this:
"//usa-qa/QAEngr/QA_Team_VSripathi/Negar/Help files/broken/header_test/main.htm"
They are located on a company's internal network.
I tried this piece of code:
import urllib
import urllib.request as ur
address="//usa-qa/QAEngr/QA_Team_VSripathi/Negar/Help files/broken/header_test/main.htm"
info=ur.urlopen(address)
which results in the following error:
Traceback (most recent call last):
File "C:/Users/naref/Desktop/networktest.py", line 14, in <module>
info=ur.urlopen(address)
File "C:\Python33\lib\urllib\request.py", line 160, in urlopen
return opener.open(url, data, timeout)
File "C:\Python33\lib\urllib\request.py", line 458, in open
req = Request(fullurl, data)
File "C:\Python33\lib\urllib\request.py", line 279, in __init__
self._parse()
File "C:\Python33\lib\urllib\request.py", line 284, in _parse
raise ValueError("unknown url type: %s" % self.full_url)
ValueError: unknown url type: //usa-qa/QAEngr/QA_Team_VSripathi/Negar/Help files/broken/header_test/main.htm
The same happens when converting the path to url:
info=ur.urlopen(ur.pathname2url(address))
Then I tried to add an "http:" to the beginning of the address:
address="http://usa-qa/QAEngr/QA_Team_VSripathi/Negar/Help files/broken/header_test/main.htm"
info=ur.urlopen(address)
Which results in the following error:
Traceback (most recent call last):
File "C:/Users/naref/Desktop/networktest.py", line 14, in <module>
info=ur.urlopen(address)
File "C:\Python33\lib\urllib\request.py", line 160, in urlopen
return opener.open(url, data, timeout)
File "C:\Python33\lib\urllib\request.py", line 473, in open
response = self._open(req, data)
File "C:\Python33\lib\urllib\request.py", line 491, in _open
'_open', req)
File "C:\Python33\lib\urllib\request.py", line 451, in _call_chain
result = func(*args)
File "C:\Python33\lib\urllib\request.py", line 1272, in http_open
return self.do_open(http.client.HTTPConnection, req)
File "C:\Python33\lib\urllib\request.py", line 1255, in do_open
raise URLError(err)
urllib.error.URLError:<urlopen error [WinError 10061] No connection could be made because the target machine actively refused it>
It is interesting that this problem gets solved when I map the network drive on my computer which runs windows 8: (http://windows.microsoft.com/en-us/windows-8/create-shortcut-to-map-network-drive)
Also the file can be opened with the open function instead of the urlopen, however I prefer to use urlopen since for my purpose the address might be a website's url.

Resources