Run_in_executor' from 'langchain_core.runnables.config'

from langchain.embeddings.openai import OpenAIEmbeddings

embedding = OpenAIEmbeddings()
I get error cannot import name ‘run_in_executor’ from ‘langchain_core.runnables.config’ (C:\Users\Lenovo\anaconda3\lib\site-packages\langchain_core\runnables\config.py)
How to start with correct code

Hi @sanjeev7

welcome to the community.

Are you trying to run locally? If so, you have to install all the packages and setup your envirioment first.

Best regards

Hi elirod,
I used the same code as on the video. Still not able to run
! pip install langchain
! pip install openai
import os
import openai
import sys
sys.path.append(‘…/…’)

from dotenv import load_dotenv, find_dotenv
_ = load_dotenv(find_dotenv()) # read local .env file

openai.api_key = os.environ[‘OPENAI_API_KEY’]

Error: cannot import name ‘run_in_executor’ from ‘langchain_core.runnables.config’ (C:\Users\Lenovo\anaconda3\lib\site-packages\langchain_core\runnables\config.py)

Hi @sanjeev7

Looks like it is something missing on your envirioment.

Keep in mind that the short courses wasn’t design to run locally. There are some config details such as API key, for example, that you have to set up by your own.

One possible solution is to make sure that all you envirioment variable are setup correctly.

The error above it is pointing out that a ‘run_in_executor’ module/method/package is missing. Or wasn’t found

This is a langchain issue, where your ok langchain_core and your langchain versions are mismatched. This causes some weird interactions, but should be fine if you just update to latest (try pip install langchain>=0.0534 in the terminal or !pip… in a notebook cell).

To begin debugging, just check it out langchain/libs/core/langchain_core/runnables/config.py at v0.0.352 · langchain-ai/langchain · GitHub and toggle between v0.0.352 and v0.0.354 tags, and you’ll notice that one of your files are coming from a mix of these.

1 Like

Hi @Vadim_Kudlay

Welcome to the community.

Thanks for your contribution. =)