pythonopenai-apirenpy

Ren'Py : ModuleNotFoundError: No module named 'netrc'


Trying to plug openai's API to Ren'Py (to make characters answer to the player)

I installed the openai python module in Ren'Py using this pip command :

pip install --target /Users/...../GameName/game/python-packages netrc

And then inside the game I use this to import the module (as expalined in the Ren'Py documentation here : https://www.renpy.org/doc/html/python.html

init python:
    import openai

But I get this error :

File "python-packages/aiohttp/helpers.py", line 9, in ModuleNotFoundError: No module named 'netrc'

I guess it means that Ren'Py runs a custom python environment without netrc, but I don't know how to install netrc as a module in Ren'Py

Any help would be greatly appreciated, I'll gladly open source this GPT-3 powered Ren'Py project once it starts working.


Solution

  • Renpy 8.0.3 doesn't ship with the necessary packages of the Python standard library (in this case 'netrc' and '_multibytecodec'). I asked the main developer about it. He now included more of the standard library as part of the Renpy nightly build, which of course will make its way into the next release.

    The current nightly build supports the required modules.

    So importing the openai module as described earlier is now possible. Just make sure to delete the "certifi" module from python-packages, as it is already part of the Renpy environment.