danmou / onenote_export

This Python script exports all the OneNote notebooks linked to your Microsoft account to HTML files.
MIT License
175 stars 42 forks source link

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

Open maphew opened 2 years ago

maphew commented 2 years ago
(onenote) PS C:\Users\Matt\code\onenote_export> python .\onenote_export.py
 * Serving Flask app 'onenote_export' (lazy loading)
 * Environment: production
   WARNING: This is a development server. Do not use it in a production deployment.
   Use a production WSGI server instead.
 * Debug mode: on
Traceback (most recent call last):
...snip...
  File "C:\ProgramData\scoop\apps\miniconda3\current\lib\site-packages\werkzeug\serving.py", line 984, in run_simple
    s.bind(server_address)
OSError: [WinError 10013] An attempt was made to access a socket in a way forbidden by its access permissions

This error occurs because the port 5000 is already in use by another application. Identify what's using the port with netstat -na | findstr "5000" and pslist with whatever process ID netstat reports (right most number). (thank you https://stackoverflow.com/questions/2778840/socket-error-errno-10013-an-attempt-was-made-to-access-a-socket-in-a-way-forb)

(onenote) PS C:\Users\Matt\code\onenote_export> netstat -ano|findstr "5000"
  TCP    0.0.0.0:5000           0.0.0.0:0              LISTENING       9348

(onenote) PS C:\Users\Matt\code\onenote_export> pslist 9348
...snip...
Name                Pid Pri Thd  Hnd   Priv        CPU Time    Elapsed Time
svchost            9348  8   9  386   5144     0:00:00.312    72:35:48.549

At this point you can kill the process with pskill {process_id}, if you know you don't want whatever that other program is doing (svchost in my example). Or change the port being used in onenote_exporter.py, and the associated Azure app (from setup portion of Readme).

maphew commented 2 years ago

it's netstat -ano not netstat -an. o adds the owning process-id to the output,