When I try to build and deploy my website, I suddenly get the error No module named 'PIL'
. I successfully built and deployed my site three days ago, and other than adding a new article no code has been changed.
The site in question is loopwerk-io / loopwerk.io (site id 9399ab89-5aeb-4801-85e3-8fb33484743d).
Deploy log looks fine, it does install Pillow from the requirements.txt file:
1:14:49 PM: build-image version: 2d47f031309907ee9f7423b4af847bb0fc945178 (focal)
1:14:49 PM: buildbot version: 054a159a518c5c7bbaa93625c60649bd215db880
1:14:49 PM: Fetching cached dependencies
1:14:49 PM: Starting to download cache of 652.4MB
1:14:51 PM: Finished downloading cache in 1.708s
1:14:51 PM: Starting to extract cache
1:14:55 PM: Finished extracting cache in 4.434s
1:14:55 PM: Finished fetching cache in 6.211s
1:14:55 PM: Starting to prepare the repo for build
1:14:55 PM: Preparing Git Reference refs/heads/master
1:14:57 PM: Custom build command detected. Proceeding with the specified command: 'swift run Loopwerk createArticleImages && npm install -g html-minifier && html-minifier --collapse-whitespace --input-dir deploy --file-ext html --output-dir deploy'
1:14:57 PM: Starting to install dependencies
1:14:58 PM: downloading cpython-3.8.20+20241002-x86_64-unknown-linux-gnu-install_only_stripped.tar.gz
1:14:58 PM: installing cpython-3.8.20+20241002-x86_64-unknown-linux-gnu-install_only_stripped.tar.gz
1:14:58 PM: python --version
1:14:58 PM: Python 3.8.20
1:14:58 PM: mise python@3.8.20 ✓ installed
1:14:58 PM: Python version set to 3.8
1:14:58 PM: Installing pip dependencies from requirements.txt
1:14:58 PM: Started restoring cached pip cache
1:14:58 PM: Finished restoring cached pip cache
1:15:00 PM: Collecting pillow==10.3.0 (from -r requirements.txt (line 1))
1:15:00 PM: Downloading pillow-10.3.0-cp38-cp38-manylinux_2_28_x86_64.whl.metadata (9.2 kB)
1:15:00 PM: Downloading pillow-10.3.0-cp38-cp38-manylinux_2_28_x86_64.whl (4.5 MB)
1:15:00 PM: ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 4.5/4.5 MB 57.4 MB/s eta 0:00:00
1:15:00 PM: Installing collected packages: pillow
1:15:00 PM: Successfully installed pillow-10.3.0
1:15:00 PM: [notice] A new release of pip is available: 24.1.2 -> 24.2
1:15:00 PM: [notice] To update, run: pip install --upgrade pip
1:15:00 PM: Pip dependencies installed
1:15:00 PM: Attempting Ruby version 2.6.2, read from environment
1:15:01 PM: Required ruby-2.6.2 is not installed - installing.
1:15:01 PM: Searching for binary rubies, this might take some time.
1:15:01 PM: Found remote file https://rubies.travis-ci.org/ubuntu/20.04/x86_64/ruby-2.6.2.tar.bz2
1:15:01 PM: Checking requirements for ubuntu.
1:15:02 PM: Requirements installation successful.
1:15:02 PM: ruby-2.6.2 - #configure
1:15:02 PM: ruby-2.6.2 - #download
1:15:03 PM: No checksum for downloaded archive, recording checksum in user configuration.
1:15:03 PM: ruby-2.6.2 - #validate archive
1:15:07 PM: ruby-2.6.2 - #extract
1:15:08 PM: ruby-2.6.2 - #validate binary
1:15:08 PM: ruby-2.6.2 - #setup
1:15:09 PM: ruby-2.6.2 - #gemset created /opt/buildhome/.rvm/gems/ruby-2.6.2@global
1:15:09 PM: ruby-2.6.2 - #importing gemset /opt/buildhome/.rvm/gemsets/global.gems........................................
1:15:09 PM: ruby-2.6.2 - #generating global wrappers........
1:15:09 PM: ruby-2.6.2 - #gemset created /opt/buildhome/.rvm/gems/ruby-2.6.2
1:15:09 PM: ruby-2.6.2 - #importing gemsetfile /opt/buildhome/.rvm/gemsets/default.gems evaluated to empty gem list
1:15:10 PM: ruby-2.6.2 - #generating default wrappers........
1:15:10 PM: Using /opt/buildhome/.rvm/gems/ruby-2.6.2
1:15:10 PM: Using Ruby version 2.6.2
1:15:11 PM: Started restoring cached go cache
1:15:11 PM: Finished restoring cached go cache
1:15:11 PM: Installing Go version 1.12 (requested 1.12)
1:15:14 PM: go version go1.12 linux/amd64
1:15:15 PM: Attempting Swift version '5.5' from .swift-version
1:15:15 PM: Started restoring cached Swift version
1:15:16 PM: Finished restoring cached Swift version
1:15:16 PM: 5.5 is already installed.
1:15:16 PM: Using Swift version 5.5
1:15:16 PM: Building Swift package
1:15:16 PM: Started restoring cached swift build
1:15:16 PM: Finished restoring cached swift build
1:15:18 PM: [1/1] Planning build
1:15:19 PM: [1/46] Compiling CMarkGFM xml.c
1:15:19 PM: [2/46] Compiling CMarkGFM tasklist.c
1:15:19 PM: [3/46] Wrapping AST for PythonKit for debugging
1:15:19 PM: [4/46] Wrapping AST for Swim for debugging
1:15:19 PM: [5/46] Wrapping AST for PathKit for debugging
1:15:19 PM: [6/46] Compiling CMarkGFM utf8.c
1:15:19 PM: [7/46] Compiling CMarkGFM tagfilter.c
1:15:19 PM: [8/46] Compiling CMarkGFM table.c
1:15:19 PM: [9/46] Compiling CMarkGFM syntax_extension.c
1:15:19 PM: [10/46] Wrapping AST for SwiftSoup for debugging
1:15:19 PM: [11/46] Wrapping AST for Codextended for debugging
1:15:19 PM: [12/46] Compiling CMarkGFM strikethrough.c
1:15:19 PM: [13/46] Compiling CMarkGFM render.c
1:15:19 PM: [14/46] Compiling CMarkGFM registry.c
1:15:19 PM: [15/46] Wrapping AST for HTML for debugging
1:15:19 PM: [16/46] Compiling CMarkGFM references.c
1:15:19 PM: [17/46] Compiling CMarkGFM plugin.c
1:15:19 PM: [18/46] Compiling CMarkGFM plaintext.c
1:15:19 PM: [19/46] Compiling CMarkGFM node.c
1:15:19 PM: [20/46] Compiling CMarkGFM map.c
1:15:19 PM: [21/46] Compiling CMarkGFM man.c
1:15:19 PM: [22/46] Compiling CMarkGFM linked_list.c
1:15:19 PM: [23/46] Wrapping AST for Saga for debugging
1:15:19 PM: [24/46] Compiling CMarkGFM scanners.c
1:15:19 PM: [25/46] Compiling CMarkGFM iterator.c
1:15:19 PM: [26/46] Compiling CMarkGFM latex.c
1:15:19 PM: [27/46] Compiling CMarkGFM html.c
1:15:19 PM: [28/46] Compiling CMarkGFM houdini_html_e.c
1:15:19 PM: [29/46] Compiling CMarkGFM houdini_html_u.c
1:15:19 PM: [30/46] Compiling CMarkGFM houdini_href_e.c
1:15:19 PM: [31/46] Compiling CMarkGFM inlines.c
1:15:19 PM: [32/46] Compiling CMarkGFM footnotes.c
1:15:19 PM: [33/46] Compiling CMarkGFM core-extensions.c
1:15:19 PM: [34/46] Compiling CMarkGFM ext_scanners.c
1:15:19 PM: [35/46] Wrapping AST for SagaSwimRenderer for debugging
1:15:19 PM: [36/46] Compiling CMarkGFM cmark_ctype.c
1:15:19 PM: [37/46] Compiling CMarkGFM cmark.c
1:15:19 PM: [38/46] Compiling CMarkGFM buffer.c
1:15:19 PM: [39/46] Compiling CMarkGFM commonmark.c
1:15:19 PM: [40/46] Compiling CMarkGFM arena.c
1:15:19 PM: [41/46] Compiling CMarkGFM autolink.c
1:15:19 PM: [42/46] Compiling CMarkGFM blocks.c
1:15:19 PM: [43/46] Wrapping AST for Parsley for debugging
1:15:20 PM: [44/46] Wrapping AST for SagaParsleyMarkdownReader for debugging
1:15:21 PM: [45/58] Compiling Loopwerk RenderPage.swift
1:15:21 PM: [46/58] Compiling Loopwerk RenderProjects.swift
1:15:21 PM: [47/58] Compiling Loopwerk RenderTagFeed.swift
1:15:21 PM: [48/58] Compiling Loopwerk RenderArticle.swift
1:15:21 PM: [49/58] Compiling Loopwerk RenderArticles.swift
1:15:21 PM: [50/58] Compiling Loopwerk RenderFeed.swift
1:15:22 PM: [51/58] Compiling Loopwerk run.swift
1:15:22 PM: [52/58] Compiling Loopwerk BaseLayout.swift
1:15:22 PM: [53/58] Compiling Loopwerk RenderApps.swift
1:15:22 PM: [54/58] Compiling Loopwerk Array+Safe.swift
1:15:22 PM: [55/58] Compiling Loopwerk Extensions.swift
1:15:22 PM: [56/58] Compiling Loopwerk String+Extensions.swift
1:15:22 PM: [58/60] Merging module Loopwerk
1:15:22 PM: [60/61] Wrapping AST for Loopwerk for debugging
1:15:22 PM: [61/61] Linking Loopwerk
1:15:22 PM: [61/61] Build complete!
1:15:22 PM: Swift package built
1:15:22 PM: Using PHP version 8.0
1:15:24 PM: Started restoring cached Node.js version
1:15:25 PM: Finished restoring cached Node.js version
1:15:25 PM: v10.24.1 is already installed.
1:15:25 PM: Now using node v10.24.1 (npm v6.14.12)
1:15:25 PM: Started restoring cached build plugins
1:15:25 PM: Finished restoring cached build plugins
1:15:26 PM: Successfully installed dependencies
1:15:26 PM: Starting build script
1:15:27 PM: Detected 0 framework(s)
1:15:27 PM: Section completed: initializing
But then in the building step it fails:
1:15:28 PM: Netlify Build
1:15:28 PM: ────────────────────────────────────────────────────────────────
1:15:28 PM:
1:15:28 PM: ❯ Version
1:15:28 PM: @netlify/build 29.55.4
1:15:28 PM:
1:15:28 PM: ❯ Flags
1:15:28 PM: accountId: 5c8ab833bd40d2d1d90d032c
1:15:28 PM: baseRelDir: false
1:15:28 PM: buildId: 6718da9ba04c4e6370ab8c09
1:15:28 PM: deployId: 6718da9ba04c4e6370ab8c0b
1:15:29 PM:
1:15:29 PM: ❯ Current directory
1:15:29 PM: /opt/build/repo
1:15:29 PM:
1:15:29 PM: ❯ Config file
1:15:29 PM: /opt/build/repo/netlify.toml
1:15:29 PM:
1:15:29 PM: ❯ Context
1:15:29 PM: production
1:15:29 PM:
1:15:29 PM: build.command from netlify.toml
1:15:29 PM: ────────────────────────────────────────────────────────────────
1:15:29 PM:
1:15:29 PM: $ swift run Loopwerk createArticleImages && npm install -g html-minifier && html-minifier --collapse-whitespace --input-dir deploy --file-ext html --output-dir deploy
1:15:30 PM: [1/1] Planning build
1:15:30 PM: [0/0] Build complete!
1:15:35 PM: Failed during stage 'building site': Build script returned non-zero exit code: 2 (https://ntl.fyi/exit-code-2)
1:15:35 PM: PythonKit/Python.swift:674: Fatal error: 'try!' expression unexpectedly raised an error: Python exception: No module named 'PIL'
1:15:35 PM: Traceback:
1:15:35 PM: File "/opt/build/repo/Sources/ImageGenerator/__init__.py", line 4, in <module>
1:15:35 PM: from PIL import Image, ImageDraw, ImageFont
1:15:35 PM: Current stack trace:
1:15:35 PM: 0 libswiftCore.so 0x00007fef31031a10 swift_reportError + 50
1:15:35 PM: 1 libswiftCore.so 0x00007fef310aa1a0 _swift_stdlib_reportFatalErrorInFile + 109
1:15:35 PM: 2 libswiftCore.so 0x00007fef30db74d2 <unavailable> + 1414354
1:15:35 PM: 3 libswiftCore.so 0x00007fef30db71fb <unavailable> + 1413627
1:15:35 PM: 4 libswiftCore.so 0x00007fef30db5ee0 _assertionFailure(_:_:file:line:flags:) + 447
1:15:35 PM: 5 libswiftCore.so 0x00007fef30dff6a0 swift_unexpectedError + 770
1:15:35 PM: 6 Loopwerk 0x0000560b6453ae2f <unavailable> + 2260527
1:15:35 PM: 7 Loopwerk 0x0000560b644ec5cf <unavailable> + 1938895
1:15:35 PM: 8 Loopwerk 0x0000560b644ea9a3 <unavailable> + 1931683
1:15:35 PM: 9 libswift_Concurrency.so 0x00007fef311fb55b <unavailable> + 251227
1:15:35 PM: 10 libswift_Concurrency.so 0x00007fef311fbb10 swift_job_run + 72
1:15:35 PM: 11 libdispatch.so 0x00007fef30a5abe6 <unavailable> + 191462
1:15:35 PM: 12 libdispatch.so 0x00007fef30a5b7f9 <unavailable> + 194553
1:15:35 PM: 13 libdispatch.so 0x00007fef30a63142 <unavailable> + 225602
1:15:35 PM: 14 libpthread.so.0 0x00007fef30ad1609 <unavailable> + 34313
1:15:35 PM: 15 libc.so.6 0x00007fef30910310 clone + 67
1:15:35 PM: bash: line 1: 8161 Illegal instruction (core dumped) swift run Loopwerk createArticleImages
1:15:35 PM:
1:15:35 PM: "build.command" failed
1:15:35 PM: ────────────────────────────────────────────────────────────────
1:15:35 PM:
1:15:35 PM: Error message
1:15:35 PM: Command failed with exit code 132: swift run Loopwerk createArticleImages && npm install -g html-minifier && html-minifier --collapse-whitespace --input-dir deploy --file-ext html --output-dir deploy (https://ntl.fyi/exit-code-132)
1:15:35 PM:
1:15:35 PM: Error location
1:15:35 PM: In build.command from netlify.toml:
1:15:35 PM: swift run Loopwerk createArticleImages && npm install -g html-minifier && html-minifier --collapse-whitespace --input-dir deploy --file-ext html --output-dir deploy
1:15:35 PM:
1:15:35 PM: Resolved config
1:15:35 PM: build:
1:15:35 PM: command: swift run Loopwerk createArticleImages && npm install -g html-minifier && html-minifier --collapse-whitespace --input-dir deploy --file-ext html --output-dir deploy
1:15:35 PM: commandOrigin: config
1:15:35 PM: environment:
1:15:35 PM: - SWIFT_VERSION
1:15:35 PM: publish: /opt/build/repo/deploy
1:15:35 PM: publishOrigin: config
1:15:35 PM: Build failed due to a user error: Build script returned non-zero exit code: 2
1:15:35 PM: Failing build: Failed to build site
1:15:35 PM: Finished processing build request in 46.785s
Build: Netlify
On October 20 it still worked fine (Netlify). What changed?