Cannot import Langchain and openai. - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: Data Science (https://python-forum.io/forum-44.html) +--- Thread: Cannot import Langchain and openai. (/thread-40029.html) |
Cannot import Langchain and openai. - standenman - May-21-2023 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 RE: Cannot import Langchain and openai. - snippsat - May-22-2023 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). RE: Cannot import Langchain and openai. - standenman - May-22-2023 Thanks snippsat - that worked! Thanks for your help |