1
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

【エラー対策】django-herokuのインストールのエラー対応

Posted at

1. 背景

https://qiita.com/norifumi92/items/a4b3dc4b3a1d474317c8
を基に、CSVファイルのアップロード、ダウンロード機能を実装しようとしたところ、
django-herokuのinstallでつまづいたので、備忘のために本ページを作成した。

2. 実行環境

環境

mac OS Catalina 10.15.4

3. エラーメッセージ

(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.対策

以下のコマンドを入力した。

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

(参考) https://qiita.com/nishina555/items/e23d73067a5cac182a63

5.結論

psycopg2-binaryのインストールや、postgresqlのインストールミスという情報がネット上に多数あったが、解決に結びつかなかった。
しかし、エラーメッセージのうち

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

に注目し、対策したところ解決した。
エラーメッセージをよく読み、一つ一つ対応することが重要。
最初の行のエラーに着目しすぎると、木を見て森を見ず、になる。

1
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?