Home > Blockchain >  VS Code randomly imports libraries in my Python Scripts
VS Code randomly imports libraries in my Python Scripts

Time:05-14

I feel like I am going crazy. Random libraries have started to become imported into my python scripts while working in visual studio code.

The other day, I pulled up some old code and noticed a very strange library import at the top.

from turtle import right

This had nothing to do with my program and I thought someone was pranking me - which would be quite odd to do this in this file I have not opened in months and the library import had no meaning to me.

A couple of weeks later, I start working on a different python script and within the same day, while at home, no one with me, another random library import occurs in my script.

from telnet import DO

Can someone please give me a reason why this could be happening?

CodePudding user response:

VSCode has an auto import feature. If you press enter while it suggests you some method/object, it will be automatically added as an import if it is not in the namespace already.

enter image description here

CodePudding user response:

Python auto-imports libraries from their keywords by default. You can disable this in the settings.

  • Related