Cannot install psycopg2 with Github Actions due to distutils

Viewed 256

I am trying to setup CI/CD for my Django project on Github. I deploy it to Heroku, which requires django-heroku package, which in turn depends on the psycopg2 package. When I'm trying to run this workflow:

build-django:
runs-on: ubuntu-latest
steps:
  - uses: actions/checkout@v2
  - name: Set up Python
    uses: actions/setup-python@v2
    with:
      python-version: '3.10'
  - name: Install dependencies
    run: |
      python -m pip install --upgrade pip
      pip install -r requirements.txt
  - name: Run Django Tests
    run: |
      python manage.py test

I get a huge error log which culminates in this:

Copying psycopg2.egg-info to /opt/hostedtoolcache/Python/3.10.1/x64/lib/python3.10/site-packages/psycopg2-2.9.2-py3.10.egg-info
running install_scripts
Traceback (most recent call last):
<...>
ModuleNotFoundError: No module named 'distutils.command.bdist_wininst'

Everything checks out on my machine. Why would I get this message?

The requirements.txt file is

setuptools~=44.1.1
wheel~=0.37.1
django~=3.2.9
djangorestframework~=3.12.4
pip~=20.3.4
pytz~=2021.3
sqlparse~=0.4.2
asgiref~=3.4.1
h11~=0.12.0
attrs~=21.2.0
trio~=0.19.0
outcome~=1.1.0
sniffio~=1.2.0
sortedcontainers~=2.4.0
cffi~=1.15.0
idna~=3.3
six~=1.16.0
cryptography~=36.0.1
certifi~=2021.10.8
urllib3~=1.26.7
selenium~=4.1.0
pycparser~=2.21
wsproto~=1.0.0 
gunicorn~=20.1.0
django-heroku
0 Answers
Related