I have a static site on App Platform that I cannot get to build correctly.
I am using Jinja to generate a static site from some templates. I have a script called
build.py in the root directory of the app that does this. It works locally with
python 3.8.5, so I know it’s not an issue with the script itself, but maybe the environment. I’ve also gotten the App to run just fine with just the pre-built html made by running the build script locally instead of as a part of the deployment process.
The initial section of the deployment always runs as follows:
=> Initializing build => Retrieving source code to /workspace => Selecting branch "main" => Checking out commit "[a commit hash]" => Validating environment => Building app using buildpacks => Configuring custom build command to be run at the end of the build: [see below after this section] => Running buildpack detection digitalocean/python-appdetect 0.0.2 heroku/python 0.188.4 digitalocean/procfile 0.0.3 digitalocean/custom 0.1.0 => Building app -----> Installing python-3.8.7 -----> Installing pip 20.1.1, setuptools 47.1.1 and wheel 0.34.2 -----> Installing SQLite3 rm: cannot remove '/workspace/.heroku/python/apt/state/lists': Directory not empty Sqlite3 failed to install. -----> Installing requirements with pip Collecting Jinja2==2.11.3 Downloading Jinja2-2.11.3-py2.py3-none-any.whl (125 kB) Collecting MarkupSafe==1.1.1 Downloading MarkupSafe-1.1.1-cp38-cp38-manylinux2010_x86_64.whl (32 kB) Installing collected packages: MarkupSafe, Jinja2 Successfully installed Jinja2-2.11.3 MarkupSafe-1.1.1
What comes next fails a few different ways:
When I use
python build.py as the build command, it fails with
ImportError: No module named site. Running
python -V as the build command shows that the command invokes version
python3 build.py as the build command instead fails with
Fatal Python error: Py_Initialize: Unable to get the locale encoding ModuleNotFoundError: No module named 'encodings'
python3 -V as the build command shows it invoking version
bash: python3.8: command not found
From the logs it looks like python3.8 is installed as a part of building the app, but I can’t seem to invoke it.
Is it possible to run a python script with
python3.8 as a part of the build step for a static site on App platform, and if so, how can I invoke it correctly here? Not even sure this would fix the issue, but it certainly isn’t working with python 2.6
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.
Click below to sign up and get $100 of credit to try our products over 60 days!