← All tasks
pythonlangchain-ai/langchain #12967Not a task: not reproduced

AttributeError: module 'openai' has no attribute 'Completion'

envgap__langchain-ai__langchain-12967

Original GitHub issue ↗Opened 2023-11-07

01 / FAILURE SIGNATURE

As reported upstream

ERROR: Project file:///workspace has a 'pyproject.toml' and its build backend is missing the 'build_editable' hook. Since it does not have a 'setup.py' nor a 'setup.cfg', it cannot be installed in editable mode. Consider using a build backend that supports PEP 660.
Not a benchmark task.
  • No curated issue-specific recipe or verified environment fix is available.

02 / ENVIRONMENT RECIPE

Base commit
Not freshly verified
Manifest
requirements.txt
Reproduce
Awaiting issue-specific recipe
Run under trace
Awaiting a meaningful runtime command

03 / ORIGINAL ISSUE TEXT

langchain-ai/langchain #12967 · read the original issue
### System Info

Downloading langchain-0.0.331-py3-none-any.whl (2.0 MB)

Downloading openai-1.1.1-py3-none-any.whl (217 kB)



### Who can help?

_No response_

### Information

- [ ] The official example notebooks/scripts
- [ ] My own modified scripts

### Related Components

- [ ] LLMs/Chat Models
- [ ] Embedding Models
- [ ] Prompts / Prompt Templates / Prompt Selectors
- [ ] Output Parsers
- [ ] Document Loaders
- [ ] Vector Stores / Retrievers
- [ ] Memory
- [ ] Agents / Agent Executors
- [ ] Tools / Toolkits
- [ ] Chains
- [ ] Callbacks/Tracing
- [ ] Async

### Reproduction

Run the following code in colab:



```

!pip install langchain

!pip install openai



from langchain.llms import OpenAI



OpenAI().predict("hoge")

```



You'll get:



```

---------------------------------------------------------------------------

AttributeError                            Traceback (most recent call last)

[<ipython-input-5-0eec0f4f0523>](https://localhost:8080/#) in <cell line: 4>()

      2 from langchain.llms import OpenAI

      3 

----> 4 OpenAI().predict("hoge")



3 frames

[/usr/local/lib/python3.10/dist-packages/langchain/llms/openai.py](https://localhost:8080/#) in validate_environment(cls, values)

    264             import openai

    265 

--> 266             values["client"] = openai.Completion

    267         except ImportError:

    268             raise ImportError(



AttributeError: module 'openai' has no attribute 'Completion'

```

### Expected behavior

This was working until yesterday. It's likely due to the openai dependency update.
Continue on GitHub ↗

04 / LABELS

Labels from the report text only; not yet run

No supported category has been assigned.

Label rules and the text that matched
[]

Issue-specific recipe and runtime smoke command require review against the complete issue and repository.

Legacy reproduction is generic install-only; match the actual issue failure before admission.