# No module named 'openai'

**URL:** <https://community.openai.com/t/no-module-named-openai/8303>\
**Category:** API\
**Created:** [August 24, 2021, 3:26pm UTC](https://community.openai.com/t/no-module-named-openai/8303 "2021-08-24T15:26:57Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![metaphorz](https://sea2.discourse-cdn.com/openai1/user_avatar/community.openai.com/metaphorz/32/596_2.png) [@metaphorz](https://community.openai.com/u/metaphorz)\
**Post date:** [August 24, 2021, 3:26pm UTC](https://community.openai.com/t/no-module-named-openai/8303/1 "2021-08-24T15:26:57Z")

</div>

I thought I’d play around with some python connected to GPT-3.  
I am getting the following after launching jupyter notebook on my machine, after doing  
`pip install openai (which reports back that openai is installed correctly)`  
I reviewed many online resources, but all assume that “import openai” works. Such as  
the official one from OpenAI:

> **[OpenAI API](https://beta.openai.com/docs/developer-quickstart/making-requests)**
>
> An API for accessing new AI models developed by OpenAI

`ModuleNotFoundError Traceback (most recent call last)  
 in   
1 import os  
----\> 2 import openai  
3  
4 openai.api\_key = os.getenv("\<openai\_key\>")  
5 …

ModuleNotFoundError: No module named ‘openai’

`

Has anyone seen this behavior? Maybe it is a jupyter thing. I tried a general Google search as well with no luck (although there were some links to Gym). Relaunching jupyter didn’t solve it.

---

<div class="post-metadata">

**Author:** ![daveshapautomator](https://sea2.discourse-cdn.com/openai1/user_avatar/community.openai.com/daveshapautomator/32/8779_2.png) [@daveshapautomator](https://community.openai.com/u/daveshapautomator)\
**Post date:** [August 24, 2021, 3:58pm UTC](https://community.openai.com/t/no-module-named-openai/8303/2 "2021-08-24T15:58:24Z")

</div>

Check the virtual environment and also PWD/CWD of the Jupyter instance.

> <https://github.com/jupyter/notebook/issues/1524>
>
> Hi,
> 
> I am new to Python and Anaconda. I installed anaconda and install Scipy. Wh…en I try import scipy in the Python in command prompt on the Anaconda prompt, it works fine as below 
> 
> \`\`\`
> \[Anaconda3\] C:\\Users\\me\>python
> Python 3.5.1 |Anaconda 4.0.0 (64-bit)| (default, Feb 16 2016, 09:49:46) \[MSC v.1900 64 bit (AMD64)\] on win32
> Type "help", "copyright", "credits" or "license" for more information.
> \>\>\> import scipy
> \>\>\>
> \`\`\`
> 
> But when I use the same in the Jupyter notebook, I am getting -
> 
> \`\`\`
> ImportError Traceback (most recent call last)
> \<ipython-input-3-4dc45f4c0083\> in \<module\>()
> \----\> 1 import scipy
> 
> ImportError: No module named 'scipy'
> \`\`\`
> 
> Please let me know how to solve this issue.

> <https://stackoverflow.com/questions/43120112/module-not-found-during-import-in-jupyter-notebook>

---

<div class="post-metadata">

**Author:** ![boris](https://sea2.discourse-cdn.com/openai1/user_avatar/community.openai.com/boris/32/701_2.png) [@boris](https://community.openai.com/u/boris)\
**Post date:** [August 24, 2021, 4:08pm UTC](https://community.openai.com/t/no-module-named-openai/8303/3 "2021-08-24T16:08:03Z")

</div>

Probably your pip points to a different version of python than your notebook launcher

---

<div class="post-metadata">

**Author:** ![metaphorz](https://sea2.discourse-cdn.com/openai1/user_avatar/community.openai.com/metaphorz/32/596_2.png) [@metaphorz](https://community.openai.com/u/metaphorz)\
**Post date:** [August 24, 2021, 4:28pm UTC](https://community.openai.com/t/no-module-named-openai/8303/4 "2021-08-24T16:28:50Z")

</div>

Yes, @daveshapautomator thanks for the links. I need more hacking. My pip and python are in miniconda. Here is the start of the notebook:

 ![Screen Shot 2021-08-24 at 11.26.21 AM 2](https://us1.discourse-cdn.com/openai1/original/2X/3/3cfd73456f5e4a0f9d784304339bbc96dafd4d80.png)

---

<div class="post-metadata">

**Author:** ![metaphorz](https://sea2.discourse-cdn.com/openai1/user_avatar/community.openai.com/metaphorz/32/596_2.png) [@metaphorz](https://community.openai.com/u/metaphorz)\
**Post date:** [August 24, 2021, 4:41pm UTC](https://community.openai.com/t/no-module-named-openai/8303/5 "2021-08-24T16:41:39Z")

</div>

Thanks to both of you for suggestions and fixes.

The basic solution was to make things consistent, as was suggested. I did 'conda install jupyter" because I was using another version of jupyter (which jupyter). Then I obtained an error in authorization, so I went with the traceback suggestion of

```auto
openai.api_key = "key"
 rather than
# openai.api_key = os.getenv("key")

```

Now I am getting useful Json. Now to parse it for something meaningful.

---

<div class="post-metadata">

**Author:** ![nautilus](https://sea2.discourse-cdn.com/openai1/user_avatar/community.openai.com/nautilus/32/7253_2.png) [@nautilus](https://community.openai.com/u/nautilus)\
**Post date:** [December 22, 2022, 10:27pm UTC](https://community.openai.com/t/no-module-named-openai/8303/6 "2022-12-22T22:27:10Z")

</div>

I am running it from the command prompt. Had to set the PATH:  
export PATH=“/git/openai-quickstart-python:${PATH}”

---

<div class="post-metadata">

**Author:** ![EricGT](https://sea2.discourse-cdn.com/openai1/user_avatar/community.openai.com/ericgt/32/20571_2.png) [@EricGT](https://community.openai.com/u/EricGT)\
**Post date:** [December 12, 2023, 6:58pm UTC](https://community.openai.com/t/no-module-named-openai/8303/7 "2023-12-12T18:58:34Z")

</div>

Closed on December 12, 2023, 6:58pm UTC


