For the new Canvas Run command, how/where does ChatGPT install necessary Python libraries?

I had ChatGPT write a simple Python script to print out the current time in half a dozen different time zones. When I ran the code, it installed the pytz library and executed properly.

I then added ‘import openai’ to the script and ran again and got the error: “RunModuleNotFoundError: No module named ‘openai’”.

Does anyone know if/how ChatGPT is setting up a venv to run its code? It’s not going to be very useful if I can’t install libraries. Preferably, I would give it a venv to use and install the libraries I need. Maybe I am missing something obvious.

1 Like

You need to do a “pip install openai” in the terminal to ensure you have that libraryavailble to your python installation.

As to the venv, depends if you asked for it to give you the instructions for that.

Or, perhaps you are refering to the built in code-interpreter?

1 Like

I am talking about within ChatGPT’s own sandbox. I have no way to pip install any libraries there. That’s why I am asking where its sandbox’s venv might be located so I can go install libraries as needed.

1 Like

Ahh, in the new Canvas system?

I think the set of available libraries is limited, not sure to what at this stage, but I will ask the question.

I’m making the assumption that the openai library is not installed in that sandbox as potentially it’s not got access to the internet, some investigations are required as this is all still very new

1 Like

Right, Canvas.

That is what I figured. And that is somewhat discouraging. It’s rare that I would really run code in Canvas, but it might grow on me. However, lack of libraries is a big issue.

1 Like

I’m sure they include a bunch of standard libs that are in common use, but anything with internet connectivity as its base is probably not present.

1 Like

EASY~

import os
import sys

package_name = ‘requests’

os.system(f"{sys.executable} -m pip install {package_name}")

just adjust your code in canvas