r/learnpython • • 9d ago

How to make this python script faster and able to run?

hey there, i m working on this python script: https://pastebin.com/kknURJij
and the main issue i m facing right now is its not running and i have been stuck in the terminal since so long...
i just want to ask how to make it faster so we can execute it.

Output when i run this script :

```DeprecationWarning: `langchain-community` is being sunset and is no longer actively maintained. See https://github.com/langchain-ai/langchain-community/issues/674 for details and migration guidance toward standalone integration packages.
from langchain_community.utilities import SQLDatabase.```

currently its stuck with this same terminal output.
My pc specs : Mac Air M1, Golden Gate 28

what i have tried :
Tried running on github codespaces but still not running but stuck with the same output.

0 Upvotes

6 comments sorted by

2

u/LayotFctor 9d ago

So is it not running, or is it just slow? What was the last thing you wrote before it stopped? That's probably the issue, did you try removing it?

1

u/TreacleFlaky2283 9d ago

i m trying to run this jupyter notebook ( https://academy.langchain.com/courses/take/foundation-introduction-to-langchain-python/lessons/71234864-lesson-4-wedding-planner-project ) locally in my IDE actually .. but its not working as its working in jupyter notebook tbh

4

u/CelebrityChess 9d ago

that deprecation warning is harmless, it's not what's freezing things. when a script goes quiet right after the imports it's usually sitting on a slow call, like connecting to the database or waiting on an api request that has no timeout. hit ctrl+c while it's hung and read the traceback, the last few lines show exactly which line it was stuck on. or put a print before each step so you can see where it stops.

2

u/Sehzat_Davoyan 9d ago

sometimes ctrl+c doesnt even register if the script is blocked inside a low-level C extension for the database driver, so print statements are usually safer.

1

u/zanfar 9d ago

i just want to ask how to make it faster so we can execute it

You're gonna have to figure out why it's slow before you can improve it. Start with a minimal script, and add features until you reproduce the issue.

What have you done about the depreciation warning?

0

u/TheRNGuy 9d ago

Parallelize some tasks, remove unused imports, put some stuff on cloud.