Home > OS >  Imports are incorrectly sorted and/or formatted | VS Code | Python
Imports are incorrectly sorted and/or formatted | VS Code | Python

Time:09-20

In a few of my beginner projects this strange red line underscoring one or more of my imports keeps appearing almost randomly and I can't figure out why. As the module is working perfectly fine it shouldn't have something to do regarding which Folder I open VS Code in as it can get resolved, so sys.path should also have the right path, as far as I'm concerned. Sometimes it works when I switch my imports around but often it just underscores a single import or switching them around doesn't do anything. Also when I try to let VS Code sort them, nothing happens and nothing had ever happened.

Thanks in advance for your help!

CodePudding user response:

As I didn't want to disable the auto imports like Ahmet Burak suggested, I tried to uninstall VS Code after hours of searching for solutions, reinstalled it, copied over my settings and it still wasn't working. Then I got more and more desperate, so I uninstalled it again on the next day, installed it, copied over my settings and somehow sorting imports with isort is working just fine now even though I have the same settings and setup as before. I can't explain what the issue really was but at least it is working.

So, if anyone else also has this problem, I can unfortunately not provide you with any better solutions than to reinstall and install VS Code a few times, every other solution I found online did absolutely nothing for me.

  • Related