E: Unable to locate package python3-pip

When I want to deploy the application using javascript and python I get this error message

then I tried adding python3-pip, but it didn’t work, and showed this error

Here is the Dockerfile:

# syntax = docker/dockerfile:1

# Adjust NODE_VERSION as desired
ARG NODE_VERSION=20.11.1
FROM node:${NODE_VERSION}-slim as base

LABEL fly_launch_runtime="Node.js"

# Node.js app lives here
WORKDIR /app

# Set production environment
ENV NODE_ENV="production"


# Throw-away build stage to reduce size of final image
FROM base as build

# Install node modules
COPY --link package-lock.json package.json ./
RUN npm ci


# Copy application code
COPY --link . .


# Final stage for app image
FROM base

# Install packages needed to build node modules
RUN apt-get update -qq && \
    apt-get install -y build-essential node-gyp pkg-config python-is-python3
RUN apt-get install -y chromium chromium-sandbox \
        fonts-ipafont-gothic \
        fonts-noto \
        fonts-noto-cjk \
        fonts-noto-color-emoji \
        --no-install-recommends && \
    apt-get clean && \
    rm -rf /var/lib/apt/lists /var/cache/apt/archives
RUN apt-get install -y python-is-python3
RUN apt-get install -y python3-pip


# Copy built application
COPY --from=build /app /app

RUN pip install -r requirements.txt

# Start the server by default, this can be overwritten at runtime
EXPOSE 8080
CMD [ "node", "index.js" ]

I would be very grateful for help! Thank you.

Check this part of your Dockerfile.

# Install packages needed to build node modules
RUN apt-get update -qq && \
    apt-get install -y build-essential node-gyp pkg-config python-is-python3
RUN apt-get install -y chromium chromium-sandbox \
        fonts-ipafont-gothic \
        fonts-noto \
        fonts-noto-cjk \
        fonts-noto-color-emoji \
        --no-install-recommends && \
    apt-get clean && \
    rm -rf /var/lib/apt/lists /var/cache/apt/archives

In the previous line “rm -rf…” you deleted all the lists of available packages…

So when you try to install them next:

RUN apt-get install -y python-is-python3
RUN apt-get install -y python3-pip

they can’t be found because… you deleted the list of available packages.

Instead, add these two packages (python-is-python3 and python3-pip) to the set of package you install before deleting the lists.Like this:


# Install packages needed to build node modules
RUN apt-get update -qq && \
    apt-get install -y build-essential node-gyp pkg-config python-is-python3
RUN apt-get install -y chromium chromium-sandbox \
        fonts-ipafont-gothic \
        fonts-noto \
        fonts-noto-cjk \
        fonts-noto-color-emoji \
         python-is-python3 \
         python3-pip \
        --no-install-recommends && \
    apt-get clean && \
    rm -rf /var/lib/apt/lists /var/cache/apt/archives
RUN apt-get install -y python-is-python3
RUN apt-get install -y python3-pip

(You don’t need to install python-is-python3 because you do install it in the previous RUN line, but I put it there for consistency. Up to you to decide which of the two installs to keep.)

Regards,

  • Daniel

thank you for your help it works, but when I run the python file this error appears, even though chromium can be used for puppeteer

2024-03-17T09:06:50.737 app[3d8d909fee4ed8] sin [info] Error executing Python script: Error: Command failed: python /app/command/scrap.py

2024-03-17T09:06:50.738 app[3d8d909fee4ed8] sin [info] Traceback (most recent call last):

2024-03-17T09:06:50.738 app[3d8d909fee4ed8] sin [info] File "/app/command/scrap.py", line 142, in <module>

2024-03-17T09:06:50.738 app[3d8d909fee4ed8] sin [info] dataframes = scrape_table_selenium(url)

2024-03-17T09:06:50.738 app[3d8d909fee4ed8] sin [info] ^^^^^^^^^^^^^^^^^^^^^^^^^^

2024-03-17T09:06:50.738 app[3d8d909fee4ed8] sin [info] File "/app/command/scrap.py", line 14, in scrape_table_selenium

2024-03-17T09:06:50.738 app[3d8d909fee4ed8] sin [info] driver = webdriver.Chrome(options=options)

2024-03-17T09:06:50.738 app[3d8d909fee4ed8] sin [info] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

2024-03-17T09:06:50.738 app[3d8d909fee4ed8] sin [info] File "/venv/lib/python3.11/site-packages/selenium/webdriver/chrome/webdriver.py", line 45, in __init__

2024-03-17T09:06:50.738 app[3d8d909fee4ed8] sin [info] super().__init__(

2024-03-17T09:06:50.738 app[3d8d909fee4ed8] sin [info] File "/venv/lib/python3.11/site-packages/selenium/webdriver/chromium/webdriver.py", line 61, in __init__

2024-03-17T09:06:50.738 app[3d8d909fee4ed8] sin [info] super().__init__(command_executor=executor, options=options)

2024-03-17T09:06:50.738 app[3d8d909fee4ed8] sin [info] File "/venv/lib/python3.11/site-packages/selenium/webdriver/remote/webdriver.py", line 208, in __init__

2024-03-17T09:06:50.738 app[3d8d909fee4ed8] sin [info] self.start_session(capabilities)

2024-03-17T09:06:50.738 app[3d8d909fee4ed8] sin [info] File "/venv/lib/python3.11/site-packages/selenium/webdriver/remote/webdriver.py", line 292, in start_session

2024-03-17T09:06:50.738 app[3d8d909fee4ed8] sin [info] response = self.execute(Command.NEW_SESSION, caps)["value"]

2024-03-17T09:06:50.738 app[3d8d909fee4ed8] sin [info] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

2024-03-17T09:06:50.738 app[3d8d909fee4ed8] sin [info] File "/venv/lib/python3.11/site-packages/selenium/webdriver/remote/webdriver.py", line 347, in execute

2024-03-17T09:06:50.738 app[3d8d909fee4ed8] sin [info] self.error_handler.check_response(response)

2024-03-17T09:06:50.738 app[3d8d909fee4ed8] sin [info] File "/venv/lib/python3.11/site-packages/selenium/webdriver/remote/errorhandler.py", line 229, in check_response

2024-03-17T09:06:50.738 app[3d8d909fee4ed8] sin [info] raise exception_class(message, screen, stacktrace)

2024-03-17T09:06:50.738 app[3d8d909fee4ed8] sin [info] selenium.common.exceptions.SessionNotCreatedException: Message: session not created: Chrome failed to start: exited normally.

2024-03-17T09:06:50.738 app[3d8d909fee4ed8] sin [info] (session not created: DevToolsActivePort file doesn't exist)

2024-03-17T09:06:50.738 app[3d8d909fee4ed8] sin [info] (The process started from chrome location /usr/bin/chromium is no longer running, so ChromeDriver is assuming that Chrome has crashed.)

2024-03-17T09:06:50.738 app[3d8d909fee4ed8] sin [info] Stacktrace:

2024-03-17T09:06:50.738 app[3d8d909fee4ed8] sin [info] #0 0x55f3e9d9af33 <unknown>

2024-03-17T09:06:50.738 app[3d8d909fee4ed8] sin [info] #1 0x55f3e9a92ce6 <unknown>

2024-03-17T09:06:50.738 app[3d8d909fee4ed8] sin [info] #2 0x55f3e9ac76fa <unknown>

2024-03-17T09:06:50.738 app[3d8d909fee4ed8] sin [info] #3 0x55f3e9ac36ed <unknown>

2024-03-17T09:06:50.738 app[3d8d909fee4ed8] sin [info] #4 0x55f3e9b0c71c <unknown>

2024-03-17T09:06:50.738 app[3d8d909fee4ed8] sin [info] #5 0x55f3e9affc53 <unknown>

2024-03-17T09:06:50.738 app[3d8d909fee4ed8] sin [info] #6 0x55f3e9ad0db3 <unknown>

2024-03-17T09:06:50.738 app[3d8d909fee4ed8] sin [info] #7 0x55f3e9ad177e <unknown>

2024-03-17T09:06:50.738 app[3d8d909fee4ed8] sin [info] #8 0x55f3e9d6086b <unknown>

2024-03-17T09:06:50.738 app[3d8d909fee4ed8] sin [info] #9 0x55f3e9d64885 <unknown>

2024-03-17T09:06:50.738 app[3d8d909fee4ed8] sin [info] #10 0x55f3e9d4e181 <unknown>

2024-03-17T09:06:50.738 app[3d8d909fee4ed8] sin [info] #11 0x55f3e9d65412 <unknown>

2024-03-17T09:06:50.738 app[3d8d909fee4ed8] sin [info] #12 0x55f3e9d3225f <unknown>

2024-03-17T09:06:50.738 app[3d8d909fee4ed8] sin [info] #13 0x55f3e9d89528 <unknown>

2024-03-17T09:06:50.738 app[3d8d909fee4ed8] sin [info] #14 0x55f3e9d89723 <unknown>

2024-03-17T09:06:50.738 app[3d8d909fee4ed8] sin [info] #15 0x55f3e9d9a0e4 <unknown>

2024-03-17T09:06:50.738 app[3d8d909fee4ed8] sin [info] #16 0x7fe5a81be134 <unknown>

My first assumption whenever I see that is that Chrome ran of of memory. How much memory have you assigned to your VM?

1 gb with 530 MB used

already fixed by add this code in docker file

RUN apt-get update -y && apt-get install -y wget xvfb unzip jq
RUN apt-get -y install curl
RUN apt-get install -y libxss1 libappindicator1 libgconf-2-4 \
    fonts-liberation libasound2 libnspr4 libnss3 libx11-xcb1 libxtst6 lsb-release xdg-utils \
    libgbm1 libnss3 libatk-bridge2.0-0 libgtk-3-0 libx11-xcb1 libxcb-dri3-0


# Fetch the latest version numbers and URLs for Chrome and ChromeDriver
RUN curl -s https://googlechromelabs.github.io/chrome-for-testing/last-known-good-versions-with-downloads.json > /tmp/versions.json

RUN CHROME_URL=$(jq -r '.channels.Stable.downloads.chrome[] | select(.platform=="linux64") | .url' /tmp/versions.json) && \
    wget -q --continue -O /tmp/chrome-linux64.zip $CHROME_URL && \
    unzip /tmp/chrome-linux64.zip -d /opt/chrome

RUN chmod +x /opt/chrome/chrome-linux64/chrome


RUN CHROMEDRIVER_URL=$(jq -r '.channels.Stable.downloads.chromedriver[] | select(.platform=="linux64") | .url' /tmp/versions.json) && \
    wget -q --continue -O /tmp/chromedriver-linux64.zip $CHROMEDRIVER_URL && \
    unzip /tmp/chromedriver-linux64.zip -d /opt/chromedriver && \
    chmod +x /opt/chromedriver/chromedriver-linux64/chromedriver

# Set up Chromedriver Environment variables
ENV CHROMEDRIVER_DIR /opt/chromedriver
ENV PATH $CHROMEDRIVER_DIR:$PATH

# Clean upa
RUN rm /tmp/chrome-linux64.zip /tmp/chromedriver-linux64.zip /tmp/versions.json

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.