Cannot install anvil-app-server on my VM

I’m trying to deploy my anvil app to Google Cloud following this guide.

The guide misses a few steps for me so these are what I did:

  • Create an Compute Engine instance with Ubuntu 20.04
  • Click on SSH connect
  • Run all the commands in the guide until pip install anvil-app-server. This returned a bunch of error, first with unable to find pg_config, and after I installed postresql, this happened:
    It appears you are missing some prerequisite to build the package from source.
    
    You may install a binary package by installing 'psycopg2-binary' from PyPI.
    If you want to install psycopg2 from source, please install the packages
    required for the build and try again.
    
    For further information please check the 'doc/src/install.rst' file (also at
    <https://www.psycopg.org/docs/install.html>).
    
    error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
    ----------------------------------------
ERROR: Command errored out with exit status 1: /home/phuong_anh_nguyen/env/bin/python3 -u -c 'import sys, setuptool
s, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-0d2oxca_/psycopg2/setup.py'"'"'; __file__='"'"'/tmp/pip-install-0d
2oxca_/psycopg2/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"
'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-gdod03
6g/install-record.txt --single-version-externally-managed --compile --install-headers /home/phuong_anh_nguyen/env/i
nclude/site/python3.8/psycopg2 Check the logs for full command output.
(env) phuong_anh_nguyen@webapp:~$ 

I tried

  • pip install psycopg2-binary
sudo apt-get update -y

sudo apt-get install -y python3-psycopg2`
sudo apt-get update
sudo apt-get install libpq-dev python-dev
sudo pip install psycopg2
  • pip install psycopg2 → this failed

But none of this makes pip install anvil-app-server possible. Is there anything I’m missing? My python version is 3.8.10

Update:
I tried

sudo apt-get install python3-pip

pip3 install psycopg2

and it works!

1 Like