[PYTHON] [Fehlergegenmaßnahmen] Fehlerbehandlung bei der Installation von Django-Heroku

1. Hintergrund

https://qiita.com/norifumi92/items/a4b3dc4b3a1d474317c8 Als ich versuchte, die Funktionen zum Hochladen und Herunterladen von CSV-Dateien basierend auf zu implementieren Ich bin über die Installation von Django-Heroku gestolpert und habe diese Seite als Erinnerung erstellt.

2. Ausführungsumgebung

Umgebung

mac OS Catalina 10.15.4

3. Fehlermeldung

(open3d) csv_uploader $ pip install django-heroku
Collecting django-heroku
  Using cached django_heroku-0.3.1-py2.py3-none-any.whl (6.2 kB)
Requirement already satisfied: dj-database-url>=0.5.0 in /Users/[User]/anaconda3/envs/open3d/lib/python3.7/site-packages (from django-heroku) (0.5.0)
Collecting psycopg2
  Using cached psycopg2-2.8.5.tar.gz (380 kB)
Requirement already satisfied: whitenoise in /Users/[User]/anaconda3/envs/open3d/lib/python3.7/site-packages (from django-heroku) (5.0.1)
Requirement already satisfied: django in /Users/[User]/anaconda3/envs/open3d/lib/python3.7/site-packages (from django-heroku) (3.0.3)
Requirement already satisfied: asgiref~=3.2 in /Users/[User]/anaconda3/envs/open3d/lib/python3.7/site-packages (from django->django-heroku) (3.2.3)
Requirement already satisfied: pytz in /Users/[User]/anaconda3/envs/open3d/lib/python3.7/site-packages (from django->django-heroku) (2019.3)
Requirement already satisfied: sqlparse>=0.2.2 in /Users/[User]/anaconda3/envs/open3d/lib/python3.7/site-packages (from django->django-heroku) (0.3.0)
Building wheels for collected packages: psycopg2
  Building wheel for psycopg2 (setup.py) ... error
  ERROR: Command errored out with exit status 1:
   command: /Users/[User]/anaconda3/envs/open3d/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/9k/8_b7gs7x28jgq7yrkcwd0jsr0000gn/T/pip-install-qe181bpf/psycopg2/setup.py'"'"'; __file__='"'"'/private/var/folders/9k/8_b7gs7x28jgq7yrkcwd0jsr0000gn/T/pip-install-qe181bpf/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/9k/8_b7gs7x28jgq7yrkcwd0jsr0000gn/T/pip-wheel-6om_gi_o
       cwd: /private/var/folders/9k/8_b7gs7x28jgq7yrkcwd0jsr0000gn/T/pip-install-qe181bpf/psycopg2/
  Complete output (36 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 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/Users/[User]/anaconda3/envs/open3d/include -arch x86_64 -I/Users/[User]/anaconda3/envs/open3d/include -arch x86_64 -DPSYCOPG_VERSION=2.8.5 (dt dec pq3 ext lo64) -DPG_VERSION_NUM=120002 -DHAVE_LO64=1 -I/Users/[User]/anaconda3/envs/open3d/include/python3.7m -I. -I/usr/local/include -I/usr/local/include/postgresql/server -c psycopg/psycopgmodule.c -o build/temp.macosx-10.9-x86_64-3.7/psycopg/psycopgmodule.o
  xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun
  
  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 'gcc' failed with exit status 1
  ----------------------------------------
  ERROR: Failed building wheel for psycopg2
  Running setup.py clean for psycopg2
Failed to build psycopg2
Installing collected packages: psycopg2, django-heroku
    Running setup.py install for psycopg2 ... error
    ERROR: Command errored out with exit status 1:
     command: /Users/[User]/anaconda3/envs/open3d/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/9k/8_b7gs7x28jgq7yrkcwd0jsr0000gn/T/pip-install-qe181bpf/psycopg2/setup.py'"'"'; __file__='"'"'/private/var/folders/9k/8_b7gs7x28jgq7yrkcwd0jsr0000gn/T/pip-install-qe181bpf/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/9k/8_b7gs7x28jgq7yrkcwd0jsr0000gn/T/pip-record-9ul34ulc/install-record.txt --single-version-externally-managed --compile --install-headers /Users/[User]/anaconda3/envs/open3d/include/python3.7m/psycopg2
         cwd: /private/var/folders/9k/8_b7gs7x28jgq7yrkcwd0jsr0000gn/T/pip-install-qe181bpf/psycopg2/
    Complete output (36 lines):
    running install
    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 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/Users/[User]/anaconda3/envs/open3d/include -arch x86_64 -I/Users/[User]/anaconda3/envs/open3d/include -arch x86_64 -DPSYCOPG_VERSION=2.8.5 (dt dec pq3 ext lo64) -DPG_VERSION_NUM=120002 -DHAVE_LO64=1 -I/Users/[User]/anaconda3/envs/open3d/include/python3.7m -I. -I/usr/local/include -I/usr/local/include/postgresql/server -c psycopg/psycopgmodule.c -o build/temp.macosx-10.9-x86_64-3.7/psycopg/psycopgmodule.o
    xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun
    
    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 'gcc' failed with exit status 1
    ----------------------------------------
ERROR: Command errored out with exit status 1: /Users/[User]/anaconda3/envs/open3d/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/9k/8_b7gs7x28jgq7yrkcwd0jsr0000gn/T/pip-install-qe181bpf/psycopg2/setup.py'"'"'; __file__='"'"'/private/var/folders/9k/8_b7gs7x28jgq7yrkcwd0jsr0000gn/T/pip-install-qe181bpf/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/9k/8_b7gs7x28jgq7yrkcwd0jsr0000gn/T/pip-record-9ul34ulc/install-record.txt --single-version-externally-managed --compile --install-headers /Users/[User]/anaconda3/envs/open3d/include/python3.7m/psycopg2 Check the logs for full command output.

4. Gegenmaßnahmen

Ich habe den folgenden Befehl eingegeben.

(open3d) csv_uploader $ xcode-select --install
xcode-select: note: install requested for command line developer tools

(Referenz) https://qiita.com/nishina555/items/e23d73067a5cac182a63

5. Schlussfolgerung

Es gab viele Informationen im Internet über die Installation von psycopg2-binary und den Installationsfehler von postgresql, aber es führte nicht zu einer Lösung. Aber aus der Fehlermeldung

xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun

Ich habe darauf geachtet und Maßnahmen ergriffen, um das Problem zu lösen. Es ist wichtig, die Fehlermeldung sorgfältig zu lesen und einzeln zu behandeln. Wenn Sie sich zu sehr auf den Fehler in der ersten Zeile konzentrieren, sehen Sie den Wald nicht, wenn Sie sich die Bäume ansehen.

Recommended Posts

[Fehlergegenmaßnahmen] Fehlerbehandlung bei der Installation von Django-Heroku
Fehlerbehandlung im Hauptrahmen
Jupyter-Installationsfehler
Installationsfehler von centOS 7
Python-Fehlerbehandlung
SikuliX-Fehlerbehandlung
django.db.migrations.exceptions.InconsistentMigrationHistory Fehlerbehandlung
[AWS] Zusammenfassung der Gegenmaßnahmen gegen CLI-Installationsfehler
Über tweepy Fehlerbehandlung
Fehlerbehandlung in PythonBox
GraphQL (gqlgen) Fehlerbehandlung
Um Fehlerbehandlung von Feedparser
Reaktion auf Fehler bei der Installation von mecab-python
Informationen zu FastAPI ~ Endpoint-Fehlerbehandlung ~
Gegenmaßnahmen für Schlüsselfehler des Wörterbuchtyps
Memorandum zur Fehlerbehandlung bei PyCUDA-Builds
Fehler geteilt durch 0 Behandlung von ZeroDivisionError
Fehlerbehandlung beim Aktualisieren der Fischschale