New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
imports of OpenAI and SQLDatabase don't work in .py file #13906
Comments
The errors I see when I hover over the red line are
|
er, I uninstalled PyLint from VS Code and now the red underline is gone. |
🤖 Hello @nyck33! I'm here to help you with your LangChain issues while we wait for a human maintainer. Just so you know, I'm an AI, and I'm designed to assist with bug fixing, answering questions, and helping users like you become contributors. If you have any questions or need further clarification, feel free to ask. Let's get started! Based on the information you've provided and the context from the LangChain repository, it seems like the issue might be due to how Python resolves imports in a script (.py file) versus a Jupyter notebook. In a Jupyter notebook, the working directory is the directory where the notebook is located, so relative imports work as expected. However, in a Python script, the working directory is the directory from where the script is run, which can cause issues with relative imports. To resolve this issue, you can try one of the following solutions:
from langchain.utilities.sql_database import SQLDatabase You would import like this: from libs.langchain.langchain.utilities.sql_database import SQLDatabase Remember to replace "libs" with the actual path to the directory containing the LangChain library. Please note that these solutions assume that the LangChain library is correctly installed in your environment and that the SQLDatabase class is correctly defined in the langchain.utilities.sql_database module. If this is not the case, you might need to check the installation of the LangChain library or the definition of the SQLDatabase class. Additionally, the I hope this helps! If you have any other questions or need further clarification, feel free to ask. Sources |
System Info
Ubuntu 23.10
Who can help?
@hwchase17 @agola11
Information
Related Components
Reproduction
but it works in my Jupyter notebook
https://medium.com/@muriithicliffernest/snowflake-langchain-generating-sql-queries-from-natural-language-queries-12c4e2918631 is the tutorial I followed for the .ipynb.
are the instructions to install packages in that Medium article so I matched versions for both the conda env I'm using for the .py and .ipynb. Even if I use the same
langchain-snowlfake
env for both the error is still there. See the red line underfrom langchain import OpenAI, SQLDatabase
in the right half of the image which is showinglanchain-sql.py
Expected behavior
The import should work, no red line.
The text was updated successfully, but these errors were encountered: