[Error countermeasures] django-heroku installation error handling

1. Background

https://qiita.com/norifumi92/items/a4b3dc4b3a1d474317c8 When I tried to implement the CSV file upload and download functions based on I stumbled upon installing django-heroku, so I created this page as a reminder.

2. Execution environment

environment

mac OS Catalina 10.15.4

3. Error message

(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. Countermeasures

I entered the following command.

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

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

5. Conclusion

There was a lot of information on the net about the installation of psycopg2-binary and the installation mistake of postgresql, but it did not lead to a solution. But of the error messages

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

I paid attention to and took measures to solve the problem. It is important to read the error messages carefully and deal with them one by one. If you focus too much on the error in the first line, you will see the trees and not the forest.

Recommended Posts

[Error countermeasures] django-heroku installation error handling
Mainframe error handling
Jupyter installation error
centOS 7 installation error
Python Error Handling
SikuliX error handling
django.db.migrations.exceptions.InconsistentMigrationHistory error handling
[AWS] Summary of CLI installation error countermeasures
About tweepy error handling
Error handling in PythonBox
GraphQL (gqlgen) error handling
Around feedparser error handling
Error handling when installing mecab-python
About FastAPI ~ Endpoint error handling ~
Dictionary type Key Error countermeasures
PyCUDA build error handling memorandum
Error divided by 0 Handling of ZeroDivisionError
[Error handling] peewee.IntegrityError 1451 occurs in peewee
Error handling when updating Fish shell