openai / openai-python

The official Python library for the OpenAI API

Home Page:https://pypi.org/project/openai/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

plotly missing in embeddings dependencies

whillas-yabble opened this issue · comments

ModuleNotFoundError                       Traceback (most recent call last)
Cell In [34], line 1
----> 1 from openai.embeddings_utils import get_embeddings
File ~/dev/opp/chat-intents/__venv__/lib/python3.9/site-packages/openai/embeddings_utils.py:7
      5 import numpy as np
      6 import pandas as pd
----> 7 import plotly.express as px
      8 from scipy import spatial
      9 from sklearn.decomposition import PCA

ModuleNotFoundError: No module named 'plotly'

ya

Before importing plotly you have to install it, you can use

pip install plotly

to install

Same issue is true for matplotlib, scipy, & sklearn

It would be great if these could be added to the dependency list so that pip install openai allows for usage without running into the errors. Or if there could be import checks in the embedding_utils file to only import those packages if they exist.

Hi Everyone! Yep, that looks like a bug. Some context for what the intention here was and where it probably went wrong:

We're trying to avoid overloading the main setup target with too many dependencies. Ideally, we'd like to keep it to just the core functionality (ie, not the utils files) and have requirements for things like utils under additional targets.

pip install -e "openai[embeddings]"

Was our attempt at splitting this out. We could have easily missed a few of the dependencies though. I'm happy to add these dependencies under the target, which I think will solve the issue?

If you keep meet the issue of ModuleNotFoundError: No module named 'sklearn'

Try this pip install scikit-learn.

The name of package and the hint in the traceback is different. 😅

I have run into same issue even though I have matplotlib 3.5 installed

i have recently faced the same issue were i need to import from openai.embeddings_utils import get_embedding and it depends on several other packages like matplotlib, sklearn etc .., and i fixed it using the command @hallacy mentioned it pip install openai[embeddings], and the code run without errors

why is this closed ? Kipster stated a solution on Sep 24, 2022 but I am still experiencing the same issue.

Why wouldn't you include the dependencies of plotly, scipy and sklearn in requirement when creating the openai package ? This would save everyone the hassle of downloading the packages on their own. Would probably save you some debugging later on when users are using diff versions of those tools that may not be compatible with your code

Still broken.
Also still missing: scipy, scikit-learn (note: sklearn is an unrelated pip package)

Hi Everyone! Yep, that looks like a bug. Some context for what the intention here was and where it probably went wrong:

We're trying to avoid overloading the main setup target with too many dependencies. Ideally, we'd like to keep it to just the core functionality (ie, not the utils files) and have requirements for things like utils under additional targets.

pip install -e "openai[embeddings]"

Was our attempt at splitting this out. We could have easily missed a few of the dependencies though. I'm happy to add these dependencies under the target, which I think will solve the issue?

If you found this from google like I did just now, the fix suggested here seems to work now that they've added the extras.
If you're using pipenv like me, the command is just pipenv install openai[embeddings] without the extras flag.

Still an issue if you install with pipenv install openai matplotlib and plotly are missing as dependencies.

Was looking for embeddings support pipenv install openai[embeddings] as posted by @FritzTheDev serves my use case. Thanks!