Winerror 10013 python socket

OSError: [WinError 10013] Была предпринята попытка получить доступ к сокету способом, запрещенным его разрешениями на доступ.

Я экспериментирую с использованием Huey в качестве кроссплатформенной очереди задач. Я нашел https://github.com/pjcunningham/flask-huey-example, который я клонировал и настроил virtualenv для использования conda (я работаю над окнами). Я следил за обновленным файлом readme и мне удалось запустить все три окна без ошибок, но когда я открываю http: // локальный: 6060 /

[! [введите описание изображения здесь] [2]] [2]

Я нажимаю кнопку отправки, и это прерывает процесс Huey_consumer:

$ python . envs/hueytest1/Scripts/huey_consumer.exe run_huey.huey [2018-08-06 10:19:25,949] INFO:huey.consumer:MainThread:Huey consumer started with 1 thread, PID 1704 [2018-08-06 10:19:25,949] INFO:huey.consumer:MainThread:Scheduler runs every 1 seconds. [2018-08-06 10:19:25,949] INFO:huey.consumer:MainThread:Periodic tasks are enabled. [2018-08-06 10:19:25,950] INFO:huey.consumer:MainThread:UTC is enabled. [2018-08-06 10:19:25,950] INFO:huey.consumer:MainThread:The following commands are available: + send_async_email + dummy_task [2018-08-06 10:19:39,743] INFO:huey.consumer.Worker:Worker-1:Executing queuecmd_send_async_email: ba5e092d-b1de-41cd-8b27-72d11c2b13d8 [2018-08-06 10:19:40,766] ERROR:huey.consumer.Worker:Worker-1:Unhandled exception in worker thread Traceback (most recent call last): File ". \envs\hueytest1\lib\site-packages\huey\consumer.py", line 153, in process_task self.huey.execute(task) File ". \envs\hueytest1\lib\site-packages\huey\api.py", line 271, in execute result = task.execute() File ". \envs\hueytest1\lib\site-packages\huey\api.py", line 565, in execute return func(*args, **kwargs) File "E:\ENVS\r3\hueytest1\app\tasks.py", line 23, in send_async_email mail.send(msg) File ". \envs\hueytest1\lib\site-packages\flask_mail.py", line 491, in send with self.connect() as connection: File ". \envs\hueytest1\lib\site-packages\flask_mail.py", line 144, in __enter__ self.host = self.configure_host() File ". \envs\hueytest1\lib\site-packages\flask_mail.py", line 158, in configure_host host = smtplib.SMTP(self.mail.server, self.mail.port) File ". \envs\hueytest1\lib\smtplib.py", line 251, in __init__ (code, msg) = self.connect(host, port) File ". \envs\hueytest1\lib\smtplib.py", line 336, in connect self.sock = self._get_socket(host, port, self.timeout) File ". \envs\hueytest1\lib\smtplib.py", line 307, in _get_socket self.source_address) File ". \envs\hueytest1\lib\socket.py", line 724, in create_connection raise err File ". \envs\hueytest1\lib\socket.py", line 713, in create_connection sock.connect(sa) OSError: [WinError 10013] An attempt was made to access a socket in a way forbidden by its access permissions 

Как я могу заставить это работать?

Читайте также:  Перевод системы исчисления питон

Источник

Saved searches

Use saved searches to filter your results more quickly

You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session.

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OSError: [WinError 10013] An attempt was made to access a socket in a way forbidden by its access permissions #86

OSError: [WinError 10013] An attempt was made to access a socket in a way forbidden by its access permissions #86

Comments

Expected Behavior

Trying to run quickstart on python 3.6

Actual Behavior

C:\Users\Uber-Admin\Desktop\Google Drive!GIF PROJECT\Python\Python 3.x\Requests

python quickstart.py
Traceback (most recent call last):
File «quickstart.py», line 49, in
main()
File «quickstart.py», line 30, in main
creds = flow.run_local_server()
File «C:\ProgramData\Anaconda3\lib\site-packages\google_auth_oauthlib\flow.py»
, line 407, in run_local_server
host, port, wsgi_app, handler_class=_WSGIRequestHandler)
File «C:\ProgramData\Anaconda3\lib\wsgiref\simple_server.py», line 153, in mak
e_server
server = server_class((host, port), handler_class)
File «C:\ProgramData\Anaconda3\lib\socketserver.py», line 453, in init
self.server_bind()
File «C:\ProgramData\Anaconda3\lib\wsgiref\simple_server.py», line 50, in serv
er_bind
HTTPServer.server_bind(self)
File «C:\ProgramData\Anaconda3\lib\http\server.py», line 136, in server_bind
socketserver.TCPServer.server_bind(self)
File «C:\ProgramData\Anaconda3\lib\socketserver.py», line 467, in server_bind
self.socket.bind(self.server_address)
OSError: [WinError 10013] An attempt was made to access a socket in a way forbid
den by its access permissions

Steps to Reproduce the Problem

  1. Ran quickstart.py from https://developers.google.com/gmail/api/quickstart/python
  2. Got error:
    C:\Users\Uber-Admin\Desktop\Google Drive!GIF PROJECT\Python\Python 3.x\Requests

python quickstart.py
Traceback (most recent call last):
File «quickstart.py», line 49, in
main()
File «quickstart.py», line 30, in main
creds = flow.run_local_server()
File «C:\ProgramData\Anaconda3\lib\site-packages\google_auth_oauthlib\flow.py»
, line 407, in run_local_server
host, port, wsgi_app, handler_class=_WSGIRequestHandler)
File «C:\ProgramData\Anaconda3\lib\wsgiref\simple_server.py», line 153, in mak
e_server
server = server_class((host, port), handler_class)
File «C:\ProgramData\Anaconda3\lib\socketserver.py», line 453, in init
self.server_bind()
File «C:\ProgramData\Anaconda3\lib\wsgiref\simple_server.py», line 50, in serv
er_bind
HTTPServer.server_bind(self)
File «C:\ProgramData\Anaconda3\lib\http\server.py», line 136, in server_bind
socketserver.TCPServer.server_bind(self)
File «C:\ProgramData\Anaconda3\lib\socketserver.py», line 467, in server_bind
self.socket.bind(self.server_address)
OSError: [WinError 10013] An attempt was made to access a socket in a way forbid
den by its access permissions

Specifications

  • Python version ( python —version ) Python 3.6.3 :: Anaconda custom (64-bit)
  • OS (Mac/Linux/Windows)
    My OS is Windows 7 64-bit Pro

The text was updated successfully, but these errors were encountered:

Is this NOT supposed to be run in Python 3? Does it need to be on Python 2.7?

In ‘flow.py’, I found this piece of code:

def Run(flow, launch_browser=True, http=None,
auth_host_name=’localhost’, auth_host_port_start=8085):

port 8090

Screenshot of that code in flow.py:

I am assuming you meant to change this port number to 8090, right?

Unfortunately, same result that it gives me the same error:

C:\Users\Uber\Google Drive!GIF PROJECT!NC\Calendar>python quickstart.py
Traceback (most recent call last):
File «quickstart.py», line 52, in
main()
File «quickstart.py», line 30, in main
creds = flow.run_local_server()
File «C:\ProgramData\Anaconda3\lib\site-packages\google_auth_oauthlib\flow.py»
, line 407, in run_local_server
host, port, wsgi_app, handler_class=_WSGIRequestHandler)
File «C:\ProgramData\Anaconda3\lib\wsgiref\simple_server.py», line 153, in mak
e_server
server = server_class((host, port), handler_class)
File «C:\ProgramData\Anaconda3\lib\socketserver.py», line 453, in init
self.server_bind()
File «C:\ProgramData\Anaconda3\lib\wsgiref\simple_server.py», line 50, in serv
er_bind
HTTPServer.server_bind(self)
File «C:\ProgramData\Anaconda3\lib\http\server.py», line 136, in server_bind
socketserver.TCPServer.server_bind(self)
File «C:\ProgramData\Anaconda3\lib\socketserver.py», line 467, in server_bind
self.socket.bind(self.server_address)
OSError: [WinError 10013] An attempt was made to access a socket in a way forbid
den by its access permissions

I got it to work in Python 3.6.

@doverradio Might have you try something you’re not used to. We’re going to see if port 8085 is in use or not using a command in your terminal called netstat. If it’s not in use, there’s probably some UAC or firewall issue going on.

So, your terminal has a command called netstat. NETSTAT displays all TCP and UPD connections (sockets) that are currently active. We’ll confirm that port 8085, the one you’ve used, is not in use.

To see all the sockets (each of which are displayed as «IP-address:port») that are in use, type into your terminal «netstat -a». This will show all the sockets in use. Of all these, to directly see if 8085 is in use, type:

  • ‘netstat -na | grep «8085»‘ in Bash or
  • ‘netstat -na | find «8085»‘ in cmd or
  • ‘netstat -na | find «»»8085″»»‘ in Powershell.

Let us know if 8085 is in there. If it is, change your port to something not in use. If it isn’t there, let us know, so we can see how else this error might occur.

@Crowbrammer I did netstat -na | find «8085» (I’m on Windows 7 64-Bit) but got no value returned.

I’m doing this from an @gmail.com account. Could part of this complication be due to free @gmail.com and not paid Gsuite account? I do have a paid Gsuite so I could just retry with that account. Can you confirm this can be done all within a @gmail.com account (free one)?

Not sure what is different but I retried everything on a new PC and it worked as expected from using this script below and having to re-run

from __future__ import print_function import datetime import pickle import os.path from googleapiclient.discovery import build from google_auth_oauthlib.flow import InstalledAppFlow from google.auth.transport.requests import Request # If modifying these scopes, delete the file token.pickle. SCOPES = ['https://www.googleapis.com/auth/calendar.readonly'] def main(): """Shows basic usage of the Google Calendar API. Prints the start and name of the next 10 events on the user's calendar. """ creds = None # The file token.pickle stores the user's access and refresh tokens, and is # created automatically when the authorization flow completes for the first # time. if os.path.exists('token.pickle'): with open('token.pickle', 'rb') as token: creds = pickle.load(token) # If there are no (valid) credentials available, let the user log in. if not creds or not creds.valid: if creds and creds.expired and creds.refresh_token: creds.refresh(Request()) else: flow = InstalledAppFlow.from_client_secrets_file( 'credentials.json', SCOPES) creds = flow.run_local_server() # Save the credentials for the next run with open('token.pickle', 'wb') as token: pickle.dump(creds, token) service = build('calendar', 'v3', credentials=creds) # Call the Calendar API now = datetime.datetime.utcnow().isoformat() + 'Z' # 'Z' indicates UTC time print('Getting the upcoming 10 events') events_result = service.events().list(calendarId='primary', timeMin=now, maxResults=10, singleEvents=True, orderBy='startTime').execute() events = events_result.get('items', []) if not events: print('No upcoming events found.') for event in events: start = event['start'].get('dateTime', event['start'].get('date')) print(start, event['summary']) if __name__ == '__main__': main() 

Error:
ModuleNotFoundError: No module named ‘google_auth_oauthlib’

Solution:
pip install google-auth-oauthlib

After doing these things, I ran ‘python quickstart.py’ and got Chrome window asking me to authorize. So, it appears working. Thank you!

Please let me know the type of account (free @gmail.com or paid) and within that, whether it must be a Service account or non-Service account which may be used (or both, I don’t know).

Источник

Оцените статью