microsoft / vscode-isort

Import sorting for python using the isort library.
https://marketplace.visualstudio.com/items?itemName=ms-python.isort
MIT License
83 stars 19 forks source link

[WinError 64] The specified network name is no longer available #410

Open buzzysin opened 3 months ago

buzzysin commented 3 months ago

System info: Windows 11 (Windows NT x64 10.0.22631) VS Code version 1.88.1 ms-python.isort: 2023.10.1

This issue occurs with multiple formatters. I've tried ms-python.{autopep8, black, isort} and the same error occurs:

2024-04-19 17:49:15.245 [info] Getting interpreter from ms-python.python extension for workspace <OBFUSCATED>\code-windows\robotics-grp
2024-04-19 17:49:15.247 [info] Interpreter from ms-python.python extension for <OBFUSCATED>\code-windows\robotics-grp: <OBFUSCATED>\miniconda3\python.exe
2024-04-19 17:49:15.250 [info] Server run command: <OBFUSCATED>\miniconda3\python.exe <OBFUSCATED>\.vscode\extensions\ms-python.isort-2023.13.10681007\bundled\tool\lsp_server.py
2024-04-19 17:49:15.250 [info] Server: Start requested.
2024-04-19 17:49:17.276 [info] Error on reading from the event loop self pipe
loop: <ProactorEventLoop running=True closed=False debug=False>
Traceback (most recent call last):
  File "<OBFUSCATED>\miniconda3\Lib\asyncio\windows_events.py", line 461, in finish_socket_func
    return ov.getresult()
           ^^^^^^^^^^^^^^
OSError: [WinError 64] The specified network name is no longer available

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<OBFUSCATED>\miniconda3\Lib\asyncio\proactor_events.py", line 793, in _loop_self_reading
    f.result()  # may raise
    ^^^^^^^^^^
  File "<OBFUSCATED>\miniconda3\Lib\asyncio\windows_events.py", line 798, in _poll
    value = callback(transferred, key, ov)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<OBFUSCATED>\miniconda3\Lib\asyncio\windows_events.py", line 465, in finish_socket_func
    raise ConnectionResetError(*exc.args)
ConnectionResetError: [WinError 64] The specified network name is no longer available

I expect this to be an environment or a network configuration issue on my end, but I haven't narrowed it down. Disabled my VPN, tried a different wireless channel, reset my wifi adaptor.

karthiknadig commented 3 months ago

Are you using a File share? This is common if the file share machine is somehow blocked either by firewall or antimalware, or if the share name changed.

buzzysin commented 3 months ago

Hi @karthiknadig, I am afraid I am just using the Windows file system on my local machine, no layers in-between, no WSL, etc.

karthiknadig commented 3 months ago

@buzzysin Did you update the value of any Environment variables? Did you change anything in hosts file?

buzzysin commented 3 months ago

@karthiknadig My hosts file is untouched and my environment is something like this

(Edit: removed environment variable spam to expiring pastebin link)

karthiknadig commented 3 months ago

@buzzysin What is the version of miniconda that you have? also does it fail if you use windows store python?

buzzysin commented 3 months ago

@karthiknadig

I was using Miniconda 3 Python 3.12 version 24.1.2-0 I installed the Windows Store version of Python which fixed my issue (with ms-python.black-formatter).

isort now has some other issue where it is not being recognised as a formatter. I should probably open a different ticket for that.

karthiknadig commented 3 months ago

@buzzysin I sort is import organizer, you will see that when you use the Organize Import command. It does not register as a formatter. If you want to use it as a default import organizer on save, then you need to set it like this:

  "[python]": {
    "editor.codeActionsOnSave": {
        "source.organizeImports.isort": "explicit"
    },
  },
buzzysin commented 3 months ago

Thanks for the help! For now I've switched to using the windows store version of python, which solved my problem.

karthiknadig commented 3 months ago

@buzzysin I recommend having a look at Ruff Extension (https://marketplace.visualstudio.com/items?itemName=charliermarsh.ruff). It provides isort, black, and several linters like pylint, flake8 and several flake8 plugins in a single package. It is also implemented in rust and is significantly more performant.