Trouble installing python openai on a Nextjs project with nix

Hello,

I am having trouble installing openai onto my project.

I am running a Nextjs replit that spawns a python shell and runs a script that uses requests, beautiful soup, and openai.

I was able to add requests and beautiful soup to the replit.nix file; however, when I tried to add openai it gives me the following error:
error: attribute ‘openai’ missing, at /home/runner/…/replit.nix:18:7
(use ‘–show-trace’ to show detailed location information)

I’ve also tried installing it with pip with no results. All other packages installed this way seem to work fine…

This is my current replit.nix file

{ pkgs }: {
	deps = [
  pkgs.nodejs-16_x
        pkgs.nodePackages.typescript-language-server
        pkgs.nodePackages.yarn
        pkgs.replitPackages.jest
    pkgs.python39
      pkgs.python39Packages.requests
      pkgs.python39Packages.beautifulsoup4
      pkgs.python39Packages.python-dotenv
  		pkgs.python39Packages.pip
      pkgs.python39Packages.openai
	];
}

I also tried saving things into a pyproject.toml but I’m not sure how to install it along side a package.json in the same project. Any help for this method or others would be much appreciated!

Please send me the link to your repl so I can take a look

click on the three dots in top right of files tab > show hidden files.
Change the nix channel in the .replit file to unstable, then try

lol, guessing your eyes sparkled when you saw next.js

Welcome to the community!

Hi I’m having the same issue. How to install openai python package in a nodejs repl?

Please send a link to your repl. If it’s private, Ironclad could take a look

Try setting your replit.nix file to this:

{ pkgs }: {
	deps = [
		pkgs.python39Packages.poetry
    pkgs.nodejs-18_x
    pkgs.python310Full
    pkgs.replitPackages.prybar-python310
    pkgs.replitPackages.stderred
    pkgs.nodePackages.typescript-language-server
    pkgs.yarn
    pkgs.replitPackages.jest
	];
  env = {
    PYTHON_LD_LIBRARY_PATH = pkgs.lib.makeLibraryPath [
      # Needed for pandas / numpy
      pkgs.stdenv.cc.cc.lib
      pkgs.zlib
      # Needed for pygame
      pkgs.glib
      # Needed for matplotlib
      pkgs.xorg.libX11
    ];
    PYTHONBIN = "${pkgs.python310Full}/bin/python3.10";
    LANG = "en_US.UTF-8";
    STDERREDBIN = "${pkgs.replitPackages.stderred}/bin/stderred";
    PRYBAR_PYTHON_BIN = "${pkgs.replitPackages.prybar-python310}/bin/prybar-python310";
  };
}
3 Likes