2
votes

installer psycopg2 échec de python 3.7

Je suis ce tutoriel - https://medium.com/@qazi/how-to-deploy-a-django-app-to-heroku-in-2018-the-easy-way-48a528d97f9c a>

jusqu'à présent, j'ai:

  • a créé mon application Django et l'a exécuté localement - fonctionne parfaitement
  • a écrit Procfile avec du contenu web: gunicorn project_name.wsgi
  • a importé django_heroku dans les paramètres

J'ai besoin d'installer psycopg2 donc j'ai lancé pip install psycopg2

mais j'ai obtenu l'erreur

Building wheels for collected packages: psycopg2
  Building wheel for psycopg2 (setup.py) ... error
  ERROR: Command errored out with exit status 1:
   command: /Users/niamhtohill/ios_dev/vf_api/venv/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/kk/0xnrjqj950qdky6pkv1dws4r0000gn/T/pip-install-q5q1ago2/psycopg2/setup.py'"'"'; __file__='"'"'/private/var/folders/kk/0xnrjqj950qdky6pkv1dws4r0000gn/T/pip-install-q5q1ago2/psycopg2/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d /private/var/folders/kk/0xnrjqj950qdky6pkv1dws4r0000gn/T/pip-wheel-3u2cfbpc --python-tag cp37
       cwd: /private/var/folders/kk/0xnrjqj950qdky6pkv1dws4r0000gn/T/pip-install-q5q1ago2/psycopg2/
  Complete output (144 lines):
  running bdist_wheel
  running build
  running build_py
  creating build
  creating build/lib.macosx-10.9-x86_64-3.7
  creating build/lib.macosx-10.9-x86_64-3.7/psycopg2
  copying lib/_json.py -> build/lib.macosx-10.9-x86_64-3.7/psycopg2
  copying lib/extras.py -> build/lib.macosx-10.9-x86_64-3.7/psycopg2
  copying lib/compat.py -> build/lib.macosx-10.9-x86_64-3.7/psycopg2
  copying lib/errorcodes.py -> build/lib.macosx-10.9-x86_64-3.7/psycopg2
  copying lib/tz.py -> build/lib.macosx-10.9-x86_64-3.7/psycopg2
  copying lib/_range.py -> build/lib.macosx-10.9-x86_64-3.7/psycopg2
  copying lib/_ipaddress.py -> build/lib.macosx-10.9-x86_64-3.7/psycopg2
  copying lib/_lru_cache.py -> build/lib.macosx-10.9-x86_64-3.7/psycopg2
  copying lib/__init__.py -> build/lib.macosx-10.9-x86_64-3.7/psycopg2
  copying lib/extensions.py -> build/lib.macosx-10.9-x86_64-3.7/psycopg2
  copying lib/errors.py -> build/lib.macosx-10.9-x86_64-3.7/psycopg2
  copying lib/sql.py -> build/lib.macosx-10.9-x86_64-3.7/psycopg2
  copying lib/pool.py -> build/lib.macosx-10.9-x86_64-3.7/psycopg2
  running build_ext
  building 'psycopg2._psycopg' extension
  creating build/temp.macosx-10.9-x86_64-3.7
  creating build/temp.macosx-10.9-x86_64-3.7/psycopg
  gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -arch x86_64 -g -DPSYCOPG_VERSION=2.8.3 (dt dec pq3 ext lo64) -DPG_VERSION_NUM=100005 -DHAVE_LO64=1 -I/Library/Frameworks/Python.framework/Versions/3.7/include/python3.7m -I. -I/usr/local/Cellar/postgresql/10.5/include -I/usr/local/Cellar/postgresql/10.5/include/server -c psycopg/psycopgmodule.c -o build/temp.macosx-10.9-x86_64-3.7/psycopg/psycopgmodule.o
  gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -arch x86_64 -g -DPSYCOPG_VERSION=2.8.3 (dt dec pq3 ext lo64) -DPG_VERSION_NUM=100005 -DHAVE_LO64=1 -I/Library/Frameworks/Python.framework/Versions/3.7/include/python3.7m -I. -I/usr/local/Cellar/postgresql/10.5/include -I/usr/local/Cellar/postgresql/10.5/include/server -c psycopg/green.c -o build/temp.macosx-10.9-x86_64-3.7/psycopg/green.o
  gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -arch x86_64 -g -DPSYCOPG_VERSION=2.8.3 (dt dec pq3 ext lo64) -DPG_VERSION_NUM=100005 -DHAVE_LO64=1 -I/Library/Frameworks/Python.framework/Versions/3.7/include/python3.7m -I. -I/usr/local/Cellar/postgresql/10.5/include -I/usr/local/Cellar/postgresql/10.5/include/server -c psycopg/pqpath.c -o build/temp.macosx-10.9-x86_64-3.7/psycopg/pqpath.o
  psycopg/pqpath.c:135:17: warning: implicit conversion from enumeration type 'ConnStatusType' to different enumeration type 'ExecStatusType' [-Wenum-conversion]
                  PQstatus(conn->pgconn) : PQresultStatus(*pgres)));
                  ^~~~~~~~~~~~~~~~~~~~~~
  psycopg/pqpath.c:1712:11: warning: code will never be executed [-Wunreachable-code]
      ret = 1;
            ^
  psycopg/pqpath.c:1817:17: warning: implicit conversion from enumeration type 'ConnStatusType' to different enumeration type 'ExecStatusType' [-Wenum-conversion]
                  PQstatus(curs->conn->pgconn) : PQresultStatus(curs->pgres)));
                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~

...
...
....
...
...
...
...
...
...

/adapter_qstring.o build/temp.macosx-10.9-x86_64-3.7/psycopg/microprotocols.o build/temp.macosx-10.9-x86_64-3.7/psycopg/microprotocols_proto.o build/temp.macosx-10.9-x86_64-3.7/psycopg/typecast.o -L/usr/local/lib -lpq -lssl -lcrypto -o build/lib.macosx-10.9-x86_64-3.7/psycopg2/_psycopg.cpython-37m-darwin.so
    ld: library not found for -lssl
    clang: error: linker command failed with exit code 1 (use -v to see invocation)
    error: command 'gcc' failed with exit status 1
    ----------------------------------------
ERROR: Command errored out with exit status 1: /Users/niamhtohill/ios_dev/vf_api/venv/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/kk/0xnrjqj950qdky6pkv1dws4r0000gn/T/pip-install-q5q1ago2/psycopg2/setup.py'"'"'; __file__='"'"'/private/var/folders/kk/0xnrjqj950qdky6pkv1dws4r0000gn/T/pip-install-q5q1ago2/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 /private/var/folders/kk/0xnrjqj950qdky6pkv1dws4r0000gn/T/pip-record-t0kpmijs/install-record.txt --single-version-externally-managed --compile --install-headers /Users/niamhtohill/ios_dev/vf_api/venv/bin/../include/site/python3.7/psycopg2 Check the logs for full command output.

j'ai vraiment envie de tourner en rond! avoir réessayé les étapes 10 fois

toute aide serait grandement appréciée


6 commentaires

Êtes-vous sur un Mac? Utilisez-vous un environnement virtuel?


Pourquoi est-ce tagué avec heroku ?


Copie possible de l ' erreur d'installation python pip install psycopg2


oui sur Mac sous Mojave et dans un environnement virtuel


ceci est pour le déploiement sur Heroku comme mentionné dans le tutoriel lié. L'étape est git push heroku master


Je ne pense pas que ce soit un double. mon fichier requirements.txt contient le binaire Psycopg mais pas Psycopg. c'est ce qui se brise


3 Réponses :


2
votes

Au lieu de pip install psycopg2 , essayez d'exécuter pip install psycopg2-binary .


1 commentaires

Je demande une explication.



0
votes

psycopg2 est un wrapper autour de la libpq Bibliothèque C , et donc elle nécessite cette bibliothèque (ainsi que d'autres pré-requis ) à installer avant de pouvoir exécuter avec succès pip install psycopg2 . Les erreurs que vous voyez sont probablement liées à cela.

Il existe une alternative, qui consiste à utiliser le psycopg2-binary wheel , qui est livré pré-emballé avec sa propre version des bibliothèques C (y compris libpq ), ce qui signifie que vous n'avez pas besoin de suivre toutes les étapes préalables.

$ pip install psycopg2-binary

Le seul cavaet est que psycopg2-binary n'est pas recommandé pour être utilisé dans les environnements de production.


0 commentaires

0
votes

Cela fonctionne pour moi:

pip install psycopg2-binary --user


0 commentaires