Python Forum

Full Version: Cannot import Langchain and openai.
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I have a python virtual environment set up. I have installed langchain and openai. The cmd command "(MedSpacyVenv) C:\Users\stand\MedSpacyVenv>pip freeze grep" yields: openai==0.27.7, openapi-schema-pydantic==1.2.4 as well as langchain==0.0.176.

If I run this code in VSCode:
import os 
import sys
#import openai
#import langchain

print(sys.path)
I get: ['c:\\Users\\stand\\MedSpacyVenv', 'C:\\Users\\stand\\AppData\\Local\\Programs\\Python\\Python311\\python311.zip', 'C:\\Users\\stand\\AppData\\Local\\Programs\\Python\\Python311\\DLLs', 'C:\\Users\\stand\\AppData\\Local\\Programs\\Python\\Python311\\Lib', 'C:\\Users\\stand\\AppData\\Local\\Programs\\Python\\Python311', 'C:\\Users\\stand\\AppData\\Local\\Programs\\Python\\Python311\\Lib\\site-packages']

If I run without commenting out import openai I get: "ModuleNotFoundError: No module named 'openai'"
IF I run without commenting out import langchain I get: "ModuleNotFoundError: No module named 'langchain"

I don't understand Sad
Read my other post in your Thread.
If gone run code from VS Code use most choice MedSpacyVenv as i show in image with my_env.
There are sys.executable you should test and not sys.path(which has no meaning when in VS Code when choice a interpreter).
[Image: 6KeOHi.png]
Thanks snippsat - that worked! Thanks for your help