miguelgrinberg / flasky

Companion code to my O'Reilly book "Flask Web Development", second edition.
MIT License
8.52k stars 4.2k forks source link

Postgress Error... #514

Closed Makeem49 closed 3 years ago

Makeem49 commented 3 years ago

Hello Miguel, your flask web development book has helped me a lot in build flask app. I decided to use postgress as my database. While installing it using docker, I'm getting bunch of error relation to postgress. Below is the error.


[6/9] RUN pip install -r requirements.txt:

10 3.373 Collecting Flask==0.10.1

10 4.137 Downloading Flask-0.10.1.tar.gz (544 kB)

10 5.787 Collecting gunicorn==20.1.0

10 5.960 Downloading gunicorn-20.1.0-py3-none-any.whl (79 kB)

10 6.506 Collecting werkzeug==0.14.1

10 6.687 Downloading Werkzeug-0.14.1-py2.py3-none-any.whl (322 kB)

10 7.207 Collecting Flask-WTF==0.9.5

10 7.542 Downloading Flask-WTF-0.9.5.tar.gz (245 kB)

10 8.395 Collecting WTForms-Components==0.9.7

10 8.695 Downloading WTForms-Components-0.9.7.tar.gz (28 kB)

10 9.646 Collecting psycopg2-binary==2.8.6

10 9.812 Downloading psycopg2_binary-2.8.6-cp37-cp37m-manylinux1_x86_64.whl (3.0 MB)

10 11.73 Collecting psycopg2==2.8.1

10 11.91 Downloading psycopg2-2.8.1.tar.gz (367 kB)

10 12.50 ERROR: Command errored out with exit status 1:

10 12.50 command: /usr/local/bin/python -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-wcsxn9vc/psycopg2_b4a497dc1e8e4b92830422f5326a6210/setup.py'"'"'; file='"'"'/tmp/pip-install-wcsxn9vc/psycopg2_b4a497dc1e8e4b92830422f5326a6210/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(file) if os.path.exists(file) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, file, '"'"'exec'"'"'))' egg_info --egg-base /tmp/pip-pip-egg-info-5lln_eq9

10 12.50 cwd: /tmp/pip-install-wcsxn9vc/psycopg2_b4a497dc1e8e4b92830422f5326a6210/

10 12.50 Complete output (23 lines):

10 12.50 running egg_info

10 12.50 creating /tmp/pip-pip-egg-info-5lln_eq9/psycopg2.egg-info

10 12.50 writing /tmp/pip-pip-egg-info-5lln_eq9/psycopg2.egg-info/PKG-INFO

10 12.50 writing dependency_links to /tmp/pip-pip-egg-info-5lln_eq9/psycopg2.egg-info/dependency_links.txt

10 12.50 writing top-level names to /tmp/pip-pip-egg-info-5lln_eq9/psycopg2.egg-info/top_level.txt

10 12.50 writing manifest file '/tmp/pip-pip-egg-info-5lln_eq9/psycopg2.egg-info/SOURCES.txt'

10 12.50

10 12.50 Error: pg_config executable not found.

10 12.50

10 12.50 pg_config is required to build psycopg2 from source. Please add the directory

10 12.50 containing pg_config to the $PATH or specify the full executable path with the

10 12.50 option:

10 12.50

10 12.50 python setup.py build_ext --pg-config /path/to/pg_config build ...

10 12.50

10 12.50 or with the pg_config option in 'setup.cfg'.

10 12.50

10 12.50 If you prefer to avoid building psycopg2 from source, please install the PyPI

10 12.50 'psycopg2-binary' package instead.

10 12.50

10 12.50 For further information please check the 'doc/src/install.rst' file (also at

10 12.50 http://initd.org/psycopg/docs/install.html).

10 12.50

10 12.50 ----------------------------------------

10 12.50 WARNING: Discarding https://files.pythonhosted.org/packages/52/be/f898e712f5f08131d651a62754fca82a1deb42e4e9889ad01932f770a2be/psycopg2-2.8.1.tar.gz#sha256=b4a475ce87eabc0607e068a3c704d0aa0820237ed78d493b8e2d880eb73cd7fe (from https://pypi.org/simple/psycopg2/) (requires-python:>=2.7,!=3.0.,!=3.1.,!=3.2.,!=3.3.). Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.

10 12.50 ERROR: Could not find a version that satisfies the requirement psycopg2==2.8.1 (from versions: 2.0.10, 2.0.11, 2.0.12, 2.0.13, 2.0.14, 2.2.0, 2.2.1, 2.2.2, 2.3.0, 2.3.1, 2.3.2, 2.4, 2.4.1, 2.4.2, 2.4.3, 2.4.4, 2.4.5, 2.4.6, 2.5, 2.5.1, 2.5.2, 2.5.3, 2.5.4, 2.5.5, 2.6, 2.6.1, 2.6.2, 2.7, 2.7.1, 2.7.2, 2.7.3, 2.7.3.1, 2.7.3.2, 2.7.4, 2.7.5, 2.7.6, 2.7.6.1, 2.7.7, 2.8, 2.8.1, 2.8.2, 2.8.3, 2.8.4, 2.8.5, 2.8.6)

10 12.50 ERROR: No matching distribution found for psycopg2==2.8.1

My requirement file :

Server

Flask==0.10.1 gunicorn==20.1.0 werkzeug==0.14.1

flask-wtforms

Flask-WTF==0.9.5 WTForms-Components==0.9.7

SQLAlchemy

psycopg2-binary == 2.8.6 # I did this because it was requesting for it. psycopg2==2.8.1 Flask-SQLAlchemy==2.1

test

pytest==5.1.0 pytest-cov==2.7.1 flake8==3.7.8

Tasks

redis==3.3.7

CLI.

Click==6.4

Extensions.

flask-debugtoolbar==0.10.0 Flask-Mail==0.9.1

Please kindly save me from this error. Thanks

miguelgrinberg commented 3 years ago

Try removing psycopg2 from your requirements file, leaving only psycopg2-binary. If that still causes psycopg2 to try to install, then the problem is that the base OS that you are using in your container image is not recognized as a valid binary platform by Python, so pip still attempts an install from source.

Makeem49 commented 3 years ago

I removed it and it was able to run without any error. Thanks