How to install Python "Pillow" module in a Node.js project?

I’m making a Discord.js bot and also using python code to do some things. For running the python script I am using the “child_process” package and it is working fine. However my Python script is trying to import Pillow module - "from PIL import Image, ImageFont, ImageDraw ", but Pillow just isn’t getting installed.

I already tried running pip3 install Pillow --user in the shell however it still doesn’t work. I also added this line in the Python file - os.system('pip3 install Pillow'), but still nothing. Please someone help on how to install pillow. Btw my replit.nix file looks like this :-

{ pkgs }: {
  deps = [
    # Node.JS Template
    # Python Template
  env = {
    PYTHON_LD_LIBRARY_PATH = pkgs.lib.makeLibraryPath [
      # Needed for pandas / numpy
      # Needed for pygame
      # Needed for matplotlib
    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";

It’s not possible to install and run a Python module inside of a Node.js project. They are two different programming languages, and are not compatible with each other.

What does that output to the Console?


Sure, it is… You can install any language on any Repl, no matter the template…


You can do multiple though? If so, then I guess you could run commands, but it’d just be confusing

When i add this line without the --user option, it doesn’t work. So I added --user in the end and this is what happens.

It prints this to the shell but after this is printed,

Command output: Collecting Pillow

Command output:   Downloading Pillow-10.0.0-cp39-cp39-manylinux_2_28_x86_64.whl (3.4 MB)

Command output:      ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 3.4/3.4 MB 57.2 MB/s eta 0:00:00
Command output: 

Command output: Installing collected packages: Pillow

Command output: Successfully installed Pillow-10.0.0

Error executing command: --- Logging error ---

This is followed by a lot of errors and call stack. In the end this is printed :-

Error executing command: Message: '[present-rich] %s'
Arguments: (UpgradePrompt(old='22.2.2', new='23.1.2'),)

Error executing command: Traceback (most recent call last):
  File "/home/runner/Text-2-Beluga-1/./src/code/", line 3, in <module>

Error executing command:     from PIL import Image, ImageFont, ImageDraw 
ModuleNotFoundError: No module named 'PIL'
1 Like