Anonymous
Установка psycopg2 в докер-контейнер Alpine
Сообщение
Anonymous » 03 ноя 2025, 21:37
Я пытаюсь заставить свое приложение django использовать PostgreSQL, однако пока безуспешно. Я настроил приложение на использование базы данных PostgreSQL и связал оба контейнера с помощью docker-compose.yml, но получаю сообщение об отсутствии модуля psycopg2. Я установил все зависимости следующим образом: apk --update add python3-dev, postgresql-client, postgresql-dev, musl-dev, и когда я пытаюсь установить psycopg2 с помощью pip pip3 install psycopg2, я получаю следующую ошибку:
Код: Выделить всё
Collecting psycopg2
Downloading psycopg2-2.6.2.tar.gz (376kB)
Installing collected packages: psycopg2
Running setup.py install for psycopg2
building 'psycopg2._psycopg' extension
gcc -Wno-unused-result -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -Os -fomit-frame-pointer -fPIC -DPSYCOPG_DEFAULT_PYDATETIME=1 -DPSYCOPG_VERSION="2.6.2 (dt dec pq3 ext lo64)" -DPG_VERSION_HEX=0x090409 -DHAVE_LO64=1 -I/usr/include/python3.4m -I. -I/usr/include -I/usr/include/postgresql/server -c psycopg/psycopgmodule.c -o build/temp.linux-x86_64-3.4/psycopg/psycopgmodule.o -Wdeclaration-after-statement
error: command 'gcc' failed with exit status 1
Complete output from command /usr/bin/python3.4 -c "import setuptools, tokenize;__file__='/tmp/pip-build-6wmwilb_/psycopg2/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-f8ye_ro8-record/install-record.txt --single-version-externally-managed --compile:
running install
running build
running build_py
creating build
creating build/lib.linux-x86_64-3.4
creating build/lib.linux-x86_64-3.4/psycopg2
copying lib/_json.py -> build/lib.linux-x86_64-3.4/psycopg2
copying lib/psycopg1.py -> build/lib.linux-x86_64-3.4/psycopg2
copying lib/pool.py -> build/lib.linux-x86_64-3.4/psycopg2
copying lib/__init__.py -> build/lib.linux-x86_64-3.4/psycopg2
copying lib/extensions.py -> build/lib.linux-x86_64-3.4/psycopg2
copying lib/errorcodes.py -> build/lib.linux-x86_64-3.4/psycopg2
copying lib/extras.py -> build/lib.linux-x86_64-3.4/psycopg2
copying lib/tz.py -> build/lib.linux-x86_64-3.4/psycopg2
copying lib/_range.py -> build/lib.linux-x86_64-3.4/psycopg2
creating build/lib.linux-x86_64-3.4/psycopg2/tests
copying tests/test_notify.py -> build/lib.linux-x86_64-3.4/psycopg2/tests
copying tests/test_lobject.py -> build/lib.linux-x86_64-3.4/psycopg2/tests
copying tests/test_errcodes.py -> build/lib.linux-x86_64-3.4/psycopg2/tests
copying tests/dbapi20.py -> build/lib.linux-x86_64-3.4/psycopg2/tests
copying tests/dbapi20_tpc.py -> build/lib.linux-x86_64-3.4/psycopg2/tests
copying tests/test_types_basic.py -> build/lib.linux-x86_64-3.4/psycopg2/tests
copying tests/test_dates.py -> build/lib.linux-x86_64-3.4/psycopg2/tests
copying tests/test_bugX000.py -> build/lib.linux-x86_64-3.4/psycopg2/tests
copying tests/test_copy.py -> build/lib.linux-x86_64-3.4/psycopg2/tests
copying tests/test_module.py -> build/lib.linux-x86_64-3.4/psycopg2/tests
copying tests/test_async.py -> build/lib.linux-x86_64-3.4/psycopg2/tests
copying tests/testutils.py -> build/lib.linux-x86_64-3.4/psycopg2/tests
copying tests/__init__.py -> build/lib.linux-x86_64-3.4/psycopg2/tests
copying tests/test_cancel.py -> build/lib.linux-x86_64-3.4/psycopg2/tests
copying tests/test_quote.py -> build/lib.linux-x86_64-3.4/psycopg2/tests
copying tests/test_psycopg2_dbapi20.py -> build/lib.linux-x86_64-3.4/psycopg2/tests
copying tests/test_with.py -> build/lib.linux-x86_64-3.4/psycopg2/tests
copying tests/testconfig.py -> build/lib.linux-x86_64-3.4/psycopg2/tests
copying tests/test_transaction.py -> build/lib.linux-x86_64-3.4/psycopg2/tests
copying tests/test_green.py -> build/lib.linux-x86_64-3.4/psycopg2/tests
copying tests/test_types_extras.py -> build/lib.linux-x86_64-3.4/psycopg2/tests
copying tests/test_cursor.py -> build/lib.linux-x86_64-3.4/psycopg2/tests
copying tests/test_connection.py -> build/lib.linux-x86_64-3.4/psycopg2/tests
copying tests/test_bug_gc.py -> build/lib.linux-x86_64-3.4/psycopg2/tests
copying tests/test_extras_dictcursor.py -> build/lib.linux-x86_64-3.4/psycopg2/tests
Skipping implicit fixer: buffer
Skipping implicit fixer: idioms
Skipping implicit fixer: set_literal
Skipping implicit fixer: ws_comma
running build_ext
building 'psycopg2._psycopg' extension
creating build/temp.linux-x86_64-3.4
creating build/temp.linux-x86_64-3.4/psycopg
gcc -Wno-unused-result -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -Os -fomit-frame-pointer -fPIC -DPSYCOPG_DEFAULT_PYDATETIME=1 -DPSYCOPG_VERSION="2.6.2 (dt dec pq3 ext lo64)" -DPG_VERSION_HEX=0x090409 -DHAVE_LO64=1 -I/usr/include/python3.4m -I. -I/usr/include -I/usr/include/postgresql/server -c psycopg/psycopgmodule.c -o build/temp.linux-x86_64-3.4/psycopg/psycopgmodule.o -Wdeclaration-after-statement
error: command 'gcc' failed with exit status 1
----------------------------------------
Command "/usr/bin/python3.4 -c "import setuptools, tokenize;__file__='/tmp/pip-build-6wmwilb_/psycopg2/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-f8ye_ro8-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-build-6wmwilb_/psycopg2
Я упускаю зависимость или неправильно устанавливаю psycopg2?
Подробнее здесь:
https://stackoverflow.com/questions/424 ... -container
1762195057
Anonymous
Я пытаюсь заставить свое приложение django использовать PostgreSQL, однако пока безуспешно. Я настроил приложение на использование базы данных PostgreSQL и связал оба контейнера с помощью docker-compose.yml, но получаю сообщение об отсутствии модуля psycopg2. Я установил все зависимости следующим образом: apk --update add python3-dev, postgresql-client, postgresql-dev, musl-dev, и когда я пытаюсь установить psycopg2 с помощью pip pip3 install psycopg2, я получаю следующую ошибку: [code]Collecting psycopg2 Downloading psycopg2-2.6.2.tar.gz (376kB) Installing collected packages: psycopg2 Running setup.py install for psycopg2 building 'psycopg2._psycopg' extension gcc -Wno-unused-result -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -Os -fomit-frame-pointer -fPIC -DPSYCOPG_DEFAULT_PYDATETIME=1 -DPSYCOPG_VERSION="2.6.2 (dt dec pq3 ext lo64)" -DPG_VERSION_HEX=0x090409 -DHAVE_LO64=1 -I/usr/include/python3.4m -I. -I/usr/include -I/usr/include/postgresql/server -c psycopg/psycopgmodule.c -o build/temp.linux-x86_64-3.4/psycopg/psycopgmodule.o -Wdeclaration-after-statement error: command 'gcc' failed with exit status 1 Complete output from command /usr/bin/python3.4 -c "import setuptools, tokenize;__file__='/tmp/pip-build-6wmwilb_/psycopg2/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-f8ye_ro8-record/install-record.txt --single-version-externally-managed --compile: running install running build running build_py creating build creating build/lib.linux-x86_64-3.4 creating build/lib.linux-x86_64-3.4/psycopg2 copying lib/_json.py -> build/lib.linux-x86_64-3.4/psycopg2 copying lib/psycopg1.py -> build/lib.linux-x86_64-3.4/psycopg2 copying lib/pool.py -> build/lib.linux-x86_64-3.4/psycopg2 copying lib/__init__.py -> build/lib.linux-x86_64-3.4/psycopg2 copying lib/extensions.py -> build/lib.linux-x86_64-3.4/psycopg2 copying lib/errorcodes.py -> build/lib.linux-x86_64-3.4/psycopg2 copying lib/extras.py -> build/lib.linux-x86_64-3.4/psycopg2 copying lib/tz.py -> build/lib.linux-x86_64-3.4/psycopg2 copying lib/_range.py -> build/lib.linux-x86_64-3.4/psycopg2 creating build/lib.linux-x86_64-3.4/psycopg2/tests copying tests/test_notify.py -> build/lib.linux-x86_64-3.4/psycopg2/tests copying tests/test_lobject.py -> build/lib.linux-x86_64-3.4/psycopg2/tests copying tests/test_errcodes.py -> build/lib.linux-x86_64-3.4/psycopg2/tests copying tests/dbapi20.py -> build/lib.linux-x86_64-3.4/psycopg2/tests copying tests/dbapi20_tpc.py -> build/lib.linux-x86_64-3.4/psycopg2/tests copying tests/test_types_basic.py -> build/lib.linux-x86_64-3.4/psycopg2/tests copying tests/test_dates.py -> build/lib.linux-x86_64-3.4/psycopg2/tests copying tests/test_bugX000.py -> build/lib.linux-x86_64-3.4/psycopg2/tests copying tests/test_copy.py -> build/lib.linux-x86_64-3.4/psycopg2/tests copying tests/test_module.py -> build/lib.linux-x86_64-3.4/psycopg2/tests copying tests/test_async.py -> build/lib.linux-x86_64-3.4/psycopg2/tests copying tests/testutils.py -> build/lib.linux-x86_64-3.4/psycopg2/tests copying tests/__init__.py -> build/lib.linux-x86_64-3.4/psycopg2/tests copying tests/test_cancel.py -> build/lib.linux-x86_64-3.4/psycopg2/tests copying tests/test_quote.py -> build/lib.linux-x86_64-3.4/psycopg2/tests copying tests/test_psycopg2_dbapi20.py -> build/lib.linux-x86_64-3.4/psycopg2/tests copying tests/test_with.py -> build/lib.linux-x86_64-3.4/psycopg2/tests copying tests/testconfig.py -> build/lib.linux-x86_64-3.4/psycopg2/tests copying tests/test_transaction.py -> build/lib.linux-x86_64-3.4/psycopg2/tests copying tests/test_green.py -> build/lib.linux-x86_64-3.4/psycopg2/tests copying tests/test_types_extras.py -> build/lib.linux-x86_64-3.4/psycopg2/tests copying tests/test_cursor.py -> build/lib.linux-x86_64-3.4/psycopg2/tests copying tests/test_connection.py -> build/lib.linux-x86_64-3.4/psycopg2/tests copying tests/test_bug_gc.py -> build/lib.linux-x86_64-3.4/psycopg2/tests copying tests/test_extras_dictcursor.py -> build/lib.linux-x86_64-3.4/psycopg2/tests Skipping implicit fixer: buffer Skipping implicit fixer: idioms Skipping implicit fixer: set_literal Skipping implicit fixer: ws_comma running build_ext building 'psycopg2._psycopg' extension creating build/temp.linux-x86_64-3.4 creating build/temp.linux-x86_64-3.4/psycopg gcc -Wno-unused-result -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -Os -fomit-frame-pointer -fPIC -DPSYCOPG_DEFAULT_PYDATETIME=1 -DPSYCOPG_VERSION="2.6.2 (dt dec pq3 ext lo64)" -DPG_VERSION_HEX=0x090409 -DHAVE_LO64=1 -I/usr/include/python3.4m -I. -I/usr/include -I/usr/include/postgresql/server -c psycopg/psycopgmodule.c -o build/temp.linux-x86_64-3.4/psycopg/psycopgmodule.o -Wdeclaration-after-statement error: command 'gcc' failed with exit status 1 ---------------------------------------- Command "/usr/bin/python3.4 -c "import setuptools, tokenize;__file__='/tmp/pip-build-6wmwilb_/psycopg2/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-f8ye_ro8-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-build-6wmwilb_/psycopg2 [/code] Я упускаю зависимость или неправильно устанавливаю psycopg2? Подробнее здесь: [url]https://stackoverflow.com/questions/42424108/installing-psycopg2-in-an-alpine-docker-container[/url]