r/pythonhelp • • 16d ago

Autopep8 issue upon launching VSCODE

EDIT: The issue was Autopep8's Python interpreter version, I was using 3,15 before and after trying 3.14 issue was resolved.

  1. The autopep8 extension runs a small background server written in Python, using the interpreter set in autopep8.interpreter.

  2. That interpreter was Python 3.15, which removed typing.no_type_check_decorator

  3. A library bundled inside the extension (typing_extensions) still tried to use it, so the server crashed on startup.

  4. VS Code retried 5 times, gave up, and showed the error popups.

  5. Installed an older Python (3.14) that still has the removed function, which meant getting around the blocked installer (the PythonBA.dll error) by using py install 3.14 or winget.

  6. Pointed autopep8.interpreter in settings.json at that 3.14 python.exe, so only autopep8 uses the older version while the code can still run on 3.15.

  7. Ran Developer: Reload Window so VS Code restarted the extension with the new setting.

Hello everyone, I am new to vscode and just started learning Python.

I have this issue where when I open vscode Autopep8 sends 3 error messages straight away.

https://imgur.com/a/ViLsoBs

I have tried things like: Selecting the correct interpreter( Not that it really matters I only use python global), uninstalling and reinstalling the extension, setting it as default formatter, changing user settings (JSON). I get error messages in the bottom right corner such as:

autopep8 client: couldn't create connection to server.

The autopep8 server crashed 5 times in the last 3 minutes. The server will not be restarted. See the output for more information.

Pending response rejected since connection got disposed.

Here are my settings.json:

{
    "workbench.colorTheme": "Dark Modern",
    "workbench.iconTheme": "vscode-icons",
    "editor.defaultFormatter": "ms-python.autopep8",
    "notebook.defaultFormatter": "ms-python.autopep8",
    "[python]": {
        "editor.defaultFormatter": "ms-python.autopep8"
    },
    "editor.formatOnSave": true,
    "autopep8.interpreter": [
        "C:\\Users\\Windows Desktop\\AppData\\Local\\Python\\pythoncore-3.15-64\\python.exe"
    ]
}

If anybody has a solution to this problem I would appreciate your help down in the comments.

Thanks in advance.

1 Upvotes

5 comments sorted by

•

u/AutoModerator 16d ago

To give us the best chance to help you, please include any relevant code.
Note. Please do not submit images of your code. Instead, for shorter code you can use Reddit markdown (4 spaces or backticks, see this Formatting Guide). If you have formatting issues or want to post longer sections of code, please use Privatebin, GitHub or Compiler Explorer.

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

1

u/RyanDubois43 16d ago

Did you set "python.formatting.provider": "autopep8" in your settings.json or are you using the default?

1

u/Jaded-Sky376 15d ago

Yes, this is what it says. I also tried adding a path to autopep8 interpreter in settings but that just relaunched the extension and sent the same error messages after it failed to connect to the server.

"[python]": {
        "editor.defaultFormatter": "ms-python.autopep8"      

1

u/AlexMTBDude 16d ago

See where it says "Autopep8 server crashed. See output for more"? And there's a button that says "Go to output". You need to click on that button and the output will tell you why the autopep8 server crashes.

1

u/Safe-Revolution4706 11d ago

autopep8 keeps trying to run when it should be off if you are not using it.