module

Langchain: ModuleNotFoundError: No module named 'langchain'

Langchain: ModuleNotFoundError: No module named 'langchain' Question: When I write code in VS Code, beginning with: import os from langchain.chains import RetrievalQA from langchain.llms import OpenAI from langchain.document_loaders import TextLoader I am met with the error: ModuleNotFoundError: No module named ‘langchain’ I have updated my Python to version 3.11.4, have updated pip, and reinstalled langchain. …

Total answers: 7

Module's __getattr__ is called twice

Module's __getattr__ is called twice Question: PEP-562 introduced __getattr__ for modules. While testing I noticed this magic method is called twice when called in this form: from X import Y. file_b.py: def __getattr__(name): print("__getattr__ called:", name) file_a.py: from file_b import foo, bar output: __getattr__ called: __path__ __getattr__ called: foo __getattr__ called: bar __getattr__ called: foo …

Total answers: 1

Which is the best way to define module variables in Python?

Which is the best way to define module variables in Python? Question: I am developing a project with FastAPI and I have to connect to a database. I have decided to create a module with database-related functionality, like managing the connection or getting the table’s metadata (I am using SQLAlchemy). I want to retrieve this …

Total answers: 1

Making sympy function with 2 variables

Making sympy function with 2 variables Question: I´m trying to do a piecewise function with sympy, but I can´t. It doesn´t the piecewise function. I want a simple funtion when (x,y) != (0,0) and a when (x,y) = (0,0) Can someone help me ? Thank you so much I tried this code: f_exp = sp.Piecewise((((x*y)*(x**2 …

Total answers: 1

Custom module not found python

Custom module not found python Question: I’m building a simple telegram bot and i need to create many .py files to order the project but when I try to run the code, the terminal displays this error message: from consts.Key import Values ModuleNotFoundError: No module named ‘consts’ The project folder is structured like this: | …

Total answers: 1

ImportError: cannot import name 'OrderedDict' from 'typing'

ImportError: cannot import name 'OrderedDict' from 'typing' Question: C:Usersjpala.condaenvstfpython.exe C:UsersjpalaDocumentsMLtrain.py Traceback (most recent call last): File "C:UsersjpalaDocumentsMLtrain.py", line 5, in <module> import tensorflow as tf File "C:Usersjpala.condaenvstflibsite-packagestensorflow__init__.py", line 37, in <module> from tensorflow.python.tools import module_util as _module_util File "C:Usersjpala.condaenvstflibsite-packagestensorflowpython__init__.py", line 42, in <module> from tensorflow.python import data File "C:Usersjpala.condaenvstflibsite-packagestensorflowpythondata__init__.py", line 21, in <module> from tensorflow.python.data …

Total answers: 1

Can install new PyPi module with pip, but can't import it myself?

Can install new PyPi module with pip, but can't import it myself? Question: So I’m trying to add a new script I wrote, fakesky, to PyPi as a module. I uploaded it to PyPi, and pip will let me install it successfully, but every time I try to import it, I get the following error: …

Total answers: 1

Unable to share global variable between threads with flask

Unable to share global variable between threads with flask Question: Context I’m trying to write a python flask server that answers a simple request. The data to be returned in the response is queried from a backend service. Since this query may take some time to complete, I don’t want to do it synchronously, I …

Total answers: 1