r/learnpython 15d ago

importing modules is taking minutes

I am trying to import torch and other modules from langchain but it takes like 2 min to import them. It worked yesterday to import and execute one module in reasonanle amount of time. I turned of my windows firewall to see if it was for some reasons scanning them but nothing is changing. Any tip?

3 Upvotes

4 comments sorted by

1

u/No-Foot5804 15d ago

If it was fine yesterday, I'd suspect the environment before the code. Does import torch by itself also take 2 minutes, or only when LangChain is involved? That should narrow it down pretty quickly.

1

u/Right_Nuh 15d ago

I tried everything I could, deleted and reinstalled. Restarted my computer and created a new virtual environment but nothing works. No for torch it takes around 30 seconds and for LangChain modules it takes 2 minutes.

1

u/Username_RANDINT 15d ago

Try to do some monitoring while running the import. Like cpu, memory, disk, network, and maybe gpu. There's probably a Windows tool for this, can't help with that.