Error 11001 when running SMTP with Anaconda 3 Python - python

On Udemy, the instructor is showing us how to use SMTP. I am using Jupyter Notebook (I know it's just to learn the basics then I am going to switch over to an IDE) and Anaconda (Python). When I run this I get these errors. (This happens with no port numbers, and the 2 port numbers our teacher told us 587,465. I also turned off windows firewall when doing this because that might have been interfering but it still didn't work.
Port Number 465
```smtp_object = smtplib.SMTP('smtp.gamil.com',465)
---------------------------------------------------------------------------
gaierror Traceback (most recent call last)
<ipython-input-10-cf67d6421353> in <module>
----> 1 smtp_object = smtplib.SMTP('smtp.gamil.com',465)
C:\ProgramData\Anaconda3\lib\smtplib.py in __init__(self, host, port, local_hostname, timeout, source_address)
249
250 if host:
--> 251 (code, msg) = self.connect(host, port)
252 if code != 220:
253 self.close()
C:\ProgramData\Anaconda3\lib\smtplib.py in connect(self, host, port, source_address)
334 if self.debuglevel > 0:
335 self._print_debug('connect:', (host, port))
--> 336 self.sock = self._get_socket(host, port, self.timeout)
337 self.file = None
338 (code, msg) = self.getreply()
enter code here
C:\ProgramData\Anaconda3\lib\smtplib.py in _get_socket(self, host, port, timeout)
305 self._print_debug('connect: to', (host, port), self.source_address)
306 return socket.create_connection((host, port), timeout,
--> 307 self.source_address)
308
309 def connect(self, host='localhost', port=0, source_address=None):
C:\ProgramData\Anaconda3\lib\socket.py in create_connection(address, timeout, source_address)
705 host, port = address
706 err = None
--> 707 for res in getaddrinfo(host, port, 0, SOCK_STREAM):
708 af, socktype, proto, canonname, sa = res
709 sock = None
C:\ProgramData\Anaconda3\lib\socket.py in getaddrinfo(host, port, family, type, proto, flags)
750 # and socket type values to enum constants.
751 addrlist = []
--> 752 for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
753 af, socktype, proto, canonname, sa = res
754 addrlist.append((_intenum_converter(af, AddressFamily),
gaierror: [Errno 11001] getaddrinfo failed```
Port number 587
```smtp_object = smtplib.SMTP('smtp.gamil.com',587)
---------------------------------------------------------------------------
gaierror Traceback (most recent call last)
<ipython-input-13-40083b789b9c> in <module>
----> 1 smtp_object = smtplib.SMTP('smtp.gamil.com',587)
C:\ProgramData\Anaconda3\lib\smtplib.py in __init__(self, host, port, local_hostname, timeout, source_address)
249
250 if host:
--> 251 (code, msg) = self.connect(host, port)
252 if code != 220:
253 self.close()
C:\ProgramData\Anaconda3\lib\smtplib.py in connect(self, host, port, source_address)
334 if self.debuglevel > 0:
335 self._print_debug('connect:', (host, port))
--> 336 self.sock = self._get_socket(host, port, self.timeout)
337 self.file = None
338 (code, msg) = self.getreply()
C:\ProgramData\Anaconda3\lib\smtplib.py in _get_socket(self, host, port, timeout)
305 self._print_debug('connect: to', (host, port), self.source_address)
306 return socket.create_connection((host, port), timeout,
--> 307 self.source_address)
308
309 def connect(self, host='localhost', port=0, source_address=None):
C:\ProgramData\Anaconda3\lib\socket.py in create_connection(address, timeout, source_address)
705 host, port = address
706 err = None
--> 707 for res in getaddrinfo(host, port, 0, SOCK_STREAM):
708 af, socktype, proto, canonname, sa = res
709 sock = None
C:\ProgramData\Anaconda3\lib\socket.py in getaddrinfo(host, port, family, type, proto, flags)
750 # and socket type values to enum constants.
751 addrlist = []
--> 752 for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
753 af, socktype, proto, canonname, sa = res
754 addrlist.append((_intenum_converter(af, AddressFamily),
gaierror: [Errno 11001] getaddrinfo failed```
No Port Number
```smtp_object = smtplib.SMTP('smtp.gamil.com')
---------------------------------------------------------------------------
gaierror Traceback (most recent call last)
<ipython-input-14-1655d3855dcf> in <module>
----> 1 smtp_object = smtplib.SMTP('smtp.gamil.com')
C:\ProgramData\Anaconda3\lib\smtplib.py in __init__(self, host, port, local_hostname, timeout, source_address)
249
250 if host:
--> 251 (code, msg) = self.connect(host, port)
252 if code != 220:
253 self.close()
C:\ProgramData\Anaconda3\lib\smtplib.py in connect(self, host, port, source_address)
334 if self.debuglevel > 0:
335 self._print_debug('connect:', (host, port))
--> 336 self.sock = self._get_socket(host, port, self.timeout)
337 self.file = None
338 (code, msg) = self.getreply()
C:\ProgramData\Anaconda3\lib\smtplib.py in _get_socket(self, host, port, timeout)
305 self._print_debug('connect: to', (host, port), self.source_address)
306 return socket.create_connection((host, port), timeout,
--> 307 self.source_address)
308
309 def connect(self, host='localhost', port=0, source_address=None):
C:\ProgramData\Anaconda3\lib\socket.py in create_connection(address, timeout, source_address)
705 host, port = address
706 err = None
--> 707 for res in getaddrinfo(host, port, 0, SOCK_STREAM):
708 af, socktype, proto, canonname, sa = res
709 sock = None
C:\ProgramData\Anaconda3\lib\socket.py in getaddrinfo(host, port, family, type, proto, flags)
750 # and socket type values to enum constants.
751 addrlist = []
--> 752 for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
753 af, socktype, proto, canonname, sa = res
754 addrlist.append((_intenum_converter(af, AddressFamily),
gaierror: [Errno 11001] getaddrinfo failed```

Related

can't upload file using ftplib over ssh-tunnel

I'm trying to upload a file using ftplib over an sshtunnel. I can login successfully to the remote end ftp server over this tunnel, but the program times out when trying to send the file.
import paramiko
from sshtunnel import SSHTunnelForwarder
from ftplib import FTP
USER = ["userSSH","passSSH"]
SSHPORT = 22
SSHIP = "A.B.C.D"
ROUTER_FTP_PORT = 21
REMOTE_FTP = "W.X.Y.Z"
fserver = SSHTunnelForwarder( (SSHIP, SSHPORT),
ssh_username = USER[0],
ssh_password = USER[1],
remote_bind_address = (REMOTE_FTP, ROUTER_FTP_PORT), )
fserver.start()
fport = fserver.local_bind_port
ftp = FTP()
ftp.connect("127.0.0.1",fport)
ftp.login("ftpUser","ftpPass")
file = open('lucas.cfg','rb')
ftp.storbinary('STOR lucas.cfg',file)
file.close()
I can certanly connect and login:
In [8]: ftp.connect("127.0.0.1",fport)
Out[8]: '220 FTP server ready'
In [9]: ftp.login("ftpUser","ftpPass")
Out[9]: '230 User logged in'
... but a time out rises when trying to upload the file ...
In [19]: ftp.storbinary('STOR lucas.cfg',file)
---------------------------------------------------------------------------
TimeoutError Traceback (most recent call last)
<ipython-input-19-0af0cb3b5ebf> in <module>()
----> 1 ftp.storbinary('STOR lucas.cfg',file)
/usr/lib/python3.6/ftplib.py in storbinary(self, cmd, fp, blocksize, callback, rest)
502 """
503 self.voidcmd('TYPE I')
--> 504 with self.transfercmd(cmd, rest) as conn:
505 while 1:
506 buf = fp.read(blocksize)
/usr/lib/python3.6/ftplib.py in transfercmd(self, cmd, rest)
397 def transfercmd(self, cmd, rest=None):
398 """Like ntransfercmd() but returns only the socket."""
--> 399 return self.ntransfercmd(cmd, rest)[0]
400
401 def login(self, user = '', passwd = '', acct = ''):
/usr/lib/python3.6/ftplib.py in ntransfercmd(self, cmd, rest)
359 host, port = self.makepasv()
360 conn = socket.create_connection((host, port), self.timeout,
--> 361 source_address=self.source_address)
362 try:
363 if rest is not None:
/usr/lib/python3.6/socket.py in create_connection(address, timeout, source_address)
722
723 if err is not None:
--> 724 raise err
725 else:
726 raise error("getaddrinfo returns an empty list")
/usr/lib/python3.6/socket.py in create_connection(address, timeout, source_address)
711 if source_address:
712 sock.bind(source_address)
--> 713 sock.connect(sa)
714 # Break explicitly a reference cycle
715 err = None
TimeoutError: [Errno 110] Connection timed out
any hint?
thanks!
So the thing is I was missing tunneling the data port of FTP. In order to avoid creating a second tunnel, I just used sftp instead.
server = SSHTunnelForwarder( (SSHIP, SSHPORT),
ssh_username = USER[0],
ssh_password = USER[1],
remote_bind_address = (REMOTE_SFTP, ROUTER_SFTP_PORT), )
server.start()
sftpPort = server.local_bind_port
transport = paramiko.Transport(("127.0.0.1",sftpPort))
transport.connect(None,username,password)
sftp = paramiko.SFTPClient.from_transport(transport)
sftp.put(fileLocal,fileRemote)
With the previous I can upload a file to a remote SFTP server over an SSH tunnel. Yes, is not FTP, but it worked for me.
If FTP is the only possible way, then a second ssh tunnel for the data channel will be needed.

Suddenly can't connect to twitter api using twitter python package

Yesterday everything was running smoothly. But all of a sudden today I am getting a long error message. My code:
from twitter import *
token = "..."
token_secret = "..."
consumer_key = "..."
consumer_secret = "..."
t = Twitter(auth=OAuth(token, token_secret, consumer_key, consumer_secret), retry=True)
t.statuses.home_timeline()
This gives me a long error message, with the final line being
URLError: <urlopen error [Errno -2] Name or service not known>
Edit: Here's the full error mesage:
gaierror Traceback (most recent call last)
/usr/lib64/python3.6/urllib/request.py in do_open(self, http_class, req, **http_conn_args)
1317 h.request(req.get_method(), req.selector, req.data, headers,
-> 1318 encode_chunked=req.has_header('Transfer-encoding'))
1319 except OSError as err: # timeout error
/usr/lib64/python3.6/http/client.py in request(self, method, url, body, headers, encode_chunked)
1238 """Send a complete request to the server."""
-> 1239 self._send_request(method, url, body, headers, encode_chunked)
1240
/usr/lib64/python3.6/http/client.py in _send_request(self, method, url, body, headers, encode_chunked)
1284 body = _encode(body, 'body')
-> 1285 self.endheaders(body, encode_chunked=encode_chunked)
1286
/usr/lib64/python3.6/http/client.py in endheaders(self, message_body, encode_chunked)
1233 raise CannotSendHeader()
-> 1234 self._send_output(message_body, encode_chunked=encode_chunked)
1235
/usr/lib64/python3.6/http/client.py in _send_output(self, message_body, encode_chunked)
1025 del self._buffer[:]
-> 1026 self.send(msg)
1027
/usr/lib64/python3.6/http/client.py in send(self, data)
963 if self.auto_open:
--> 964 self.connect()
965 else:
/usr/lib64/python3.6/http/client.py in connect(self)
1391
-> 1392 super().connect()
1393
/usr/lib64/python3.6/http/client.py in connect(self)
935 self.sock = self._create_connection(
--> 936 (self.host,self.port), self.timeout, self.source_address)
937 self.sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1)
/usr/lib64/python3.6/socket.py in create_connection(address, timeout, source_address)
703 err = None
--> 704 for res in getaddrinfo(host, port, 0, SOCK_STREAM):
705 af, socktype, proto, canonname, sa = res
/usr/lib64/python3.6/socket.py in getaddrinfo(host, port, family, type, proto, flags)
744 addrlist = []
--> 745 for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
746 af, socktype, proto, canonname, sa = res
gaierror: [Errno -2] Name or service not known
During handling of the above exception, another exception occurred:
URLError Traceback (most recent call last)
<ipython-input-158-181b63fa633f> in <module>
12 #t.ratelimit.RateLimit()
13 # Get your "home" timeline
---> 14 t.statuses.home_timeline()
15
16 # Get a particular friend's timeline
~/Documents/DL/myenv/lib/python3.6/site-packages/twitter/api.py in __call__(self, **kwargs)
332 return self._handle_response_with_retry(req, uri, arg_data, _timeout)
333 else:
--> 334 return self._handle_response(req, uri, arg_data, _timeout)
335
336 def _handle_response(self, req, uri, arg_data, _timeout=None):
~/Documents/DL/myenv/lib/python3.6/site-packages/twitter/api.py in _handle_response(self, req, uri, arg_data, _timeout)
339 kwargs['timeout'] = _timeout
340 try:
--> 341 handle = urllib_request.urlopen(req, **kwargs)
342 if handle.headers['Content-Type'] in ['image/jpeg', 'image/png']:
343 return handle
/usr/lib64/python3.6/urllib/request.py in urlopen(url, data, timeout, cafile, capath, cadefault, context)
221 else:
222 opener = _opener
--> 223 return opener.open(url, data, timeout)
224
225 def install_opener(opener):
/usr/lib64/python3.6/urllib/request.py in open(self, fullurl, data, timeout)
524 req = meth(req)
525
--> 526 response = self._open(req, data)
527
528 # post-process response
/usr/lib64/python3.6/urllib/request.py in _open(self, req, data)
542 protocol = req.type
543 result = self._call_chain(self.handle_open, protocol, protocol +
--> 544 '_open', req)
545 if result:
546 return result
/usr/lib64/python3.6/urllib/request.py in _call_chain(self, chain, kind, meth_name, *args)
502 for handler in handlers:
503 func = getattr(handler, meth_name)
--> 504 result = func(*args)
505 if result is not None:
506 return result
/usr/lib64/python3.6/urllib/request.py in https_open(self, req)
1359 def https_open(self, req):
1360 return self.do_open(http.client.HTTPSConnection, req,
-> 1361 context=self._context, check_hostname=self._check_hostname)
1362
1363 https_request = AbstractHTTPHandler.do_request_
/usr/lib64/python3.6/urllib/request.py in do_open(self, http_class, req, **http_conn_args)
1318 encode_chunked=req.has_header('Transfer-encoding'))
1319 except OSError as err: # timeout error
-> 1320 raise URLError(err)
1321 r = h.getresponse()
1322 except:
URLError: <urlopen error [Errno -2] Name or service not known>

smtplib/exchangelib connection to the email server error

I used to use auto discover to retrieve some emails from my inbox using exchangelib. However, last week they updated my email and auto discover is not working anymore. Now I am testing the connection with SMTPLIB using SMTP_SSL
server = smtplib.SMTP_SSL('xxxxxxxx.com',port=25)
but I get
ConnectionRefusedError: [WinError 10061]
c:\python37\lib\smtplib.py in __init__(self, host, port, local_hostname, keyfile, certfile, timeout, source_address, context)
1029 self.context = context
1030 SMTP.__init__(self, host, port, local_hostname, timeout,
-> 1031 source_address)
1032
1033 def _get_socket(self, host, port, timeout):
c:\python37\lib\smtplib.py in __init__(self, host, port, local_hostname, timeout, source_address)
249
250 if host:
--> 251 (code, msg) = self.connect(host, port)
252 if code != 220:
253 self.close()
c:\python37\lib\smtplib.py in connect(self, host, port, source_address)
334 if self.debuglevel > 0:
335 self._print_debug('connect:', (host, port))
--> 336 self.sock = self._get_socket(host, port, self.timeout)
337 self.file = None
338 (code, msg) = self.getreply()
c:\python37\lib\smtplib.py in _get_socket(self, host, port, timeout)
1035 self._print_debug('connect:', (host, port))
1036 new_socket = socket.create_connection((host, port), timeout,
-> 1037 self.source_address)
1038 new_socket = self.context.wrap_socket(new_socket,
1039 server_hostname=self._host)
c:\python37\lib\socket.py in create_connection(address, timeout, source_address)
725
726 if err is not None:
--> 727 raise err
728 else:
729 raise error("getaddrinfo returns an empty list")
c:\python37\lib\socket.py in create_connection(address, timeout, source_address)
714 if source_address:
715 sock.bind(source_address)
--> 716 sock.connect(sa)
717 # Break explicitly a reference cycle
718 err = None
ConnectionRefusedError: [WinError 10061] No connection could be made because the target machine actively refused it
When I used auto discover on exchangelib I got
AutoDiscoverFailed Traceback (most recent call last)
<ipython-input-48-c03f25ef8bb7> in <module>
5 autodiscover=True,
6 # config=self.config,
----> 7 access_type=DELEGATE
8 )
c:\python37\lib\site-packages\exchangelib\account.py in __init__(self, primary_smtp_address, fullname, access_type, autodiscover, credentials, config, locale, default_timezone)
78 raise AttributeError('config is ignored when autodiscover is active')
79 self.primary_smtp_address, self.protocol = discover(email=self.primary_smtp_address,
---> 80 credentials=credentials)
81 else:
82 if not config:
c:\python37\lib\site-packages\exchangelib\autodiscover.py in discover(email, credentials)
221 # We fell out of the with statement, so either cache was filled by someone else, or autodiscover redirected us to
222 # another email address. Start over after releasing the lock.
--> 223 return discover(email=email, credentials=credentials)
224
225
c:\python37\lib\site-packages\exchangelib\autodiscover.py in discover(email, credentials)
211 try:
212 # This eventually fills the cache in _autodiscover_hostname
--> 213 return _try_autodiscover(hostname=domain, credentials=credentials, email=email)
214 except AutoDiscoverRedirect as e:
215 if email.lower() == e.redirect_email.lower():
c:\python37\lib\site-packages\exchangelib\autodiscover.py in _try_autodiscover(hostname, credentials, email)
259 ), None)
260 log.info('autodiscover.%s redirected us to %s', hostname, e.server)
--> 261 return _try_autodiscover(e.server, credentials, email)
262 except AutoDiscoverFailed as e:
263 log.info('Autodiscover on autodiscover.%s (no TLS) failed (%s). Trying DNS records', hostname, e)
c:\python37\lib\site-packages\exchangelib\autodiscover.py in _try_autodiscover(hostname, credentials, email)
277 return _try_autodiscover(hostname=hostname_from_dns, credentials=credentials, email=email)
278 except AutoDiscoverFailed:
--> 279 raise_from(AutoDiscoverFailed('All steps in the autodiscover protocol failed'), None)
280
281
c:\python37\lib\site-packages\future\utils\__init__.py in raise_from(exc, cause)
398 myglobals['__python_future_raise_from_cause'] = cause
399 execstr = "raise __python_future_raise_from_exc from __python_future_raise_from_cause"
--> 400 exec(execstr, myglobals, mylocals)
401
402 def raise_(tp, value=None, tb=None):
c:\python37\lib\site-packages\exchangelib\autodiscover.py in <module>
AutoDiscoverFailed: All steps in the autodiscover protocol failed
I don't know how to deal with these exceptions

TimeoutError - Traceback (most recent call last), Django-app - sending e-mails. Python

I am trying to use 'mailgun' and gmail mail to send emails from my Django application, but each time I receive an error.
In my application I have the following code:
settings.py
EMAIL_HOST = 'smtp.mailgun.org'
EMAIL_PORT = 587
EMAIL_HOST_USER = 'aaa#mg.xxx.com'
EMAIL_HOST_PASSWORD = '#########'
EMAIL_USE_TLS = True
then I run the command from the command line:
manage.py shell
[1] from django.core.mail import send_mail
[2] send_mail('subject', 'body of the message', 'aaa#mg.xxx.com', ['
recipient#aaa.com'])
Do I use gmail, or with 'mailguna' always get the same error
Error:
TimeoutError Traceback (most recent call last)
<ipython-input-27-4c559962ca7f> in <module>()
----> 1 send_mail('subject', 'body of the message', '####mg.###.com', ['#######.com'])
~\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\core\mail\__init__.py in send_mail(subject, message, from_email, recipient_list, fail_silently, auth_user, auth_password, connection, html_message)
58 mail.attach_alternative(html_message, 'text/html')
59
---> 60 return mail.send()
61
62
~\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\core\mail\message.py in send(self, fail_silently)
289 # send to.
290 return 0
--> 291 return self.get_connection(fail_silently).send_messages([self])
292
293 def attach(self, filename=None, content=None, mimetype=None):
~\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\core\mail\backends\smtp.py in send_messages(self, email_messages)
101 return
102 with self._lock:
--> 103 new_conn_created = self.open()
104 if not self.connection or new_conn_created is None:
105 # We failed silently on open().
~\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\core\mail\backends\smtp.py in open(self)
61 })
62 try:
---> 63 self.connection = self.connection_class(self.host, self.port, **connection_params)
64
65 # TLS/SSL are mutually exclusive, so only attempt TLS over
~\AppData\Local\Programs\Python\Python37-32\lib\smtplib.py in __init__(self, host, port, local_hostname, timeout, source_address)
249
250 if host:
--> 251 (code, msg) = self.connect(host, port)
252 if code != 220:
253 self.close()
~\AppData\Local\Programs\Python\Python37-32\lib\smtplib.py in connect(self, host, port, source_address)
334 if self.debuglevel > 0:
335 self._print_debug('connect:', (host, port))
--> 336 self.sock = self._get_socket(host, port, self.timeout)
337 self.file = None
338 (code, msg) = self.getreply()
~\AppData\Local\Programs\Python\Python37-32\lib\smtplib.py in _get_socket(self, host, port, timeout)
305 self._print_debug('connect: to', (host, port), self.source_address)
306 return socket.create_connection((host, port), timeout,
--> 307 self.source_address)
308
309 def connect(self, host='localhost', port=0, source_address=None):
~\AppData\Local\Programs\Python\Python37-32\lib\socket.py in create_connection(address, timeout, source_address)
725
726 if err is not None:
--> 727 raise err
728 else:
729 raise error("getaddrinfo returns an empty list")
~\AppData\Local\Programs\Python\Python37-32\lib\socket.py in create_connection(address, timeout, source_address)
714 if source_address:
715 sock.bind(source_address)
--> 716 sock.connect(sa)
717 # Break explicitly a reference cycle
718 err = None
TimeoutError: [WinError 10060]
I tried to change the settings 'TLS', 'mail port' and 'SSL' but they always ended with the same error.
When the code runs outside the application everything works fine:
file_works_properly.py
import smtplib
from email.mime.text import MIMEText
msg = MIMEText('Title') #Tresc wiadomosci
msg['Subject'] = "Hello world"
msg['From'] = "XXX#mg.bbb.com"
msg['To'] = "ccc#ccc.com"
s = smtplib.SMTP('smtp.mailgun.org', 587)
s.login('####mg.bbb.com', '3###baa5e1f3###-26fa###0987')
s.sendmail(msg['From'], msg['To'], msg.as_string())
s.quit()
Every help will be appreciated.
The addition of three imports solved my problem (for 'python manage.py shell' or to the views.py file):
imports (in views.py/shell):
from django.contrib import messages
from django.core.mail import send_mail
from django.conf import settings
The rest of the activities are unchanged:
settings.py
[...]
EMAIL_USE_TLS = True
EMAIL_HOST = 'smtp.gmail.com'
EMAIL_HOST_USER = 'myemail#gmail.com'
EMAIL_HOST_PASSWORD = 'mypassowrd'
EMAIL_PORT = 587
To send e-mail (in views.py/shell)
send_mail(subject, message, from_email, [to_list_email])
(*Important for gmail.com) - and often this option must be enabled.

Python SSL: WRONG_VERSION_NUMBER (_ssl.c:590) using urllib with a proxy

This code used to run flawlessly. I haven't changed anything but tried using it from a different location, behind a proxy, and I get this error:
IOError: [Errno socket error] [SSL: WRONG_VERSION_NUMBER] wrong version number (_ssl.c:590)
Here's where it fails:
gcontext = ssl.SSLContext(ssl.PROTOCOL_TLSv1)
data = urllib.urlopen("https://itunes.apple.com/us/rss/topfreeapplications/limit=50/genre=" + str(category) + "/json", "download.txt", context = gcontext).read()
I immediately thought that the problem might come from the proxy I'm using, but don't know how to tell python to use that proxy as well. The solutions in this thread did not help me (same error).
And here's the full traceback:
IOError Traceback (most recent call last)
C:\Users\Nathan\App_Finder_2.0.1.py in <module>()
15 print "Checking category " + str(categoryCounter) + " of " + "23..." # progress
16 print "Opening iTunes RSS feed for top 50 English apps in category " + str(categoryCounter) + " of " + "23..." # progress
---> 17 data = urllib.urlopen("https://itunes.apple.com/us/rss/topfreeapplications/limit=50/genre=" + str(category) + "/json", "download.txt", context = gcontext).read() # Open data from iTunes RSS Feed. Genre = category, in English
18 d = json.loads(data) # Load data
19
C:\Users\Nathan\AppData\Local\Enthought\Canopy\App\appdata\canopy-1.6.2.3262.win-x86_64\lib\urllib.pyc in urlopen(url, data, proxies, context)
87 return opener.open(url)
88 else:
---> 89 return opener.open(url, data)
90 def urlretrieve(url, filename=None, reporthook=None, data=None, context=None):
91 global _urlopener
C:\Users\Nathan\AppData\Local\Enthought\Canopy\App\appdata\canopy-1.6.2.3262.win-x86_64\lib\urllib.pyc in open(self, fullurl, data)
213 return getattr(self, name)(url)
214 else:
--> 215 return getattr(self, name)(url, data)
216 except socket.error, msg:
217 raise IOError, ('socket error', msg), sys.exc_info()[2]
C:\Users\Nathan\AppData\Local\Enthought\Canopy\App\appdata\canopy-1.6.2.3262.win-x86_64\lib\urllib.pyc in open_https(self, url, data)
441 if realhost: h.putheader('Host', realhost)
442 for args in self.addheaders: h.putheader(*args)
--> 443 h.endheaders(data)
444 errcode, errmsg, headers = h.getreply()
445 fp = h.getfile()
C:\Users\Nathan\AppData\Local\Enthought\Canopy\App\appdata\canopy-1.6.2.3262.win-x86_64\lib\httplib.pyc in endheaders(self, message_body)
1047 else:
1048 raise CannotSendHeader()
-> 1049 self._send_output(message_body)
1050
1051 def request(self, method, url, body=None, headers={}):
C:\Users\Nathan\AppData\Local\Enthought\Canopy\App\appdata\canopy-1.6.2.3262.win-x86_64\lib\httplib.pyc in _send_output(self, message_body)
891 msg += message_body
892 message_body = None
--> 893 self.send(msg)
894 if message_body is not None:
895 #message_body was not a string (i.e. it is a file) and
C:\Users\Nathan\AppData\Local\Enthought\Canopy\App\appdata\canopy-1.6.2.3262.win-x86_64\lib\httplib.pyc in send(self, data)
853 if self.sock is None:
854 if self.auto_open:
--> 855 self.connect()
856 else:
857 raise NotConnected()
C:\Users\Nathan\AppData\Local\Enthought\Canopy\App\appdata\canopy-1.6.2.3262.win-x86_64\lib\httplib.pyc in connect(self)
1272
1273 self.sock = self._context.wrap_socket(self.sock,
-> 1274 server_hostname=server_hostname)
1275
1276 __all__.append("HTTPSConnection")
C:\Users\Nathan\AppData\Local\Enthought\Canopy\App\appdata\canopy-1.6.2.3262.win-x86_64\lib\ssl.pyc in wrap_socket(self, sock, server_side, do_handshake_on_connect, suppress_ragged_eofs, server_hostname)
350 suppress_ragged_eofs=suppress_ragged_eofs,
351 server_hostname=server_hostname,
--> 352 _context=self)
353
354 def set_npn_protocols(self, npn_protocols):
C:\Users\Nathan\AppData\Local\Enthought\Canopy\App\appdata\canopy-1.6.2.3262.win-x86_64\lib\ssl.pyc in __init__(self, sock, keyfile, certfile, server_side, cert_reqs, ssl_version, ca_certs, do_handshake_on_connect, family, type, proto, fileno, suppress_ragged_eofs, npn_protocols, ciphers, server_hostname, _context)
577 # non-blocking
578 raise ValueError("do_handshake_on_connect should not be specified for non-blocking sockets")
--> 579 self.do_handshake()
580
581 except (OSError, ValueError):
C:\Users\Nathan\AppData\Local\Enthought\Canopy\App\appdata\canopy-1.6.2.3262.win-x86_64\lib\ssl.pyc in do_handshake(self, block)
806 if timeout == 0.0 and block:
807 self.settimeout(None)
--> 808 self._sslobj.do_handshake()
809 finally:
810 self.settimeout(timeout)
Thanks a lot for your help!

Categories