Do I need to specify a module_mapping (or somethin...
# general
l
Do I need to specify a module_mapping (or something else) to get the following import to work?
from langchain.llms import BaseLLM, OpenAI
1
e
If the PyPI project name is not equal to the root package name the answer is always yes. That's the algorithm.
Is it
langchain
on PyPI?
l
yeah, it's langchain on pypi
e
So something more complex is going on.
l
The error received: `Could not import openai python package. Please it install it with
pip install openai
. (type=value_error)`
which makes no sense for that import
r
It’s optional so you need
langchain[openai]
https://github.com/hwchase17/langchain/blob/master/pyproject.toml#L43
l
I do have the
openai
package installed, but not
langchain[openai]
. I can give that a shot
e
Thanks @refined-addition-53644. @loud-spring-35539 full command lines and output is always best going forward. That missing bit you added was crucial.
l
Copy code
15:43:41.74 [WARN] Pants cannot infer owners for the following imports in the target libs/compose/compose_model.py:

  * langchain.chains.LLMChain (line: 3)
  * langchain.llms.BaseLLM (line: 4)
  * langchain.llms.OpenAI (line: 4)
  * langchain.prompts.PromptTemplate (line: 5)
Imports
Copy code
from langchain.chains import LLMChain
from langchain.llms import BaseLLM, OpenAI
from langchain.prompts import PromptTemplate
r
How are you defining your python requirements?
requirements.txt
should look like
Copy code
langchain[openai]
# or
langchain[openai] == <required_version>
l
Copy code
python-liquid==1.8.*
openai
langchain
langchain[openai]
e
Oh, langchain is you!
I thought it was 3rd party
Or is it not you?
l
it's third party
that's from my requirements.txt
r
I don’t think both
langchain
and
langchain[openai]
should be in there. Just use the extra one. Unless you’re explicitly importing
openai
somewhere in your code, you should also remove
openai
. Pants doesn’t play well with duplicate entries.
l
we do import openai explicitly in other files
👍 1
r
ok then keep that.