carsales / pyheif

Python 3.6+ interface to libheif library
Apache License 2.0
167 stars 41 forks source link

Can't install using pip #72

Closed bobby-kim-km closed 2 years ago

bobby-kim-km commented 2 years ago

I have m1 pro mac book (12.0.1)

I'm try to

$ brew install libffi libheif
$ pip install git+https://github.com/carsales/pyheif.git

error :

ERROR: Command errored out with exit status 1:
     command: /Users/bobby.kim/kine/KMProjectManager/venv/bin/python3.9 -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/bq/jgwv45vj7cg4txj07c5hs5q40000gp/T/pip-req-build-7vdioyn2/setup.py'"'"'; __file__='"'"'/private/var/folders/bq/jgwv45vj7cg4txj07c5hs5q40000gp/T/pip-req-build-7vdioyn2/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /private/var/folders/bq/jgwv45vj7cg4txj07c5hs5q40000gp/T/pip-record-as4c9ncg/install-record.txt --single-version-externally-managed --compile --install-headers /Users/bobby.kim/kine/KMProjectManager/venv/include/site/python3.9/pyheif
         cwd: /private/var/folders/bq/jgwv45vj7cg4txj07c5hs5q40000gp/T/pip-req-build-7vdioyn2/
    Complete output (25 lines):
    running install
    running build
    running build_py
    creating build
    creating build/lib.macosx-10.9-universal2-3.9
    creating build/lib.macosx-10.9-universal2-3.9/pyheif
    copying pyheif/error.py -> build/lib.macosx-10.9-universal2-3.9/pyheif
    copying pyheif/constants.py -> build/lib.macosx-10.9-universal2-3.9/pyheif
    copying pyheif/__init__.py -> build/lib.macosx-10.9-universal2-3.9/pyheif
    copying pyheif/reader.py -> build/lib.macosx-10.9-universal2-3.9/pyheif
    copying pyheif/writer.py -> build/lib.macosx-10.9-universal2-3.9/pyheif
    creating build/lib.macosx-10.9-universal2-3.9/pyheif/data
    copying pyheif/data/version.txt -> build/lib.macosx-10.9-universal2-3.9/pyheif/data
    running build_ext
    generating cffi module 'build/temp.macosx-10.9-universal2-3.9/_libheif_cffi.c'
    creating build/temp.macosx-10.9-universal2-3.9
    building '_libheif_cffi' extension
    creating build/temp.macosx-10.9-universal2-3.9/build
    creating build/temp.macosx-10.9-universal2-3.9/build/temp.macosx-10.9-universal2-3.9
    gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -arch arm64 -arch x86_64 -g -I/usr/local/include -I/usr/include -I/opt/local/include -I/Users/bobby.kim/kine/KMProjectManager/venv/include -I/Library/Frameworks/Python.framework/Versions/3.9/include/python3.9 -c build/temp.macosx-10.9-universal2-3.9/_libheif_cffi.c -o build/temp.macosx-10.9-universal2-3.9/build/temp.macosx-10.9-universal2-3.9/_libheif_cffi.o
    build/temp.macosx-10.9-universal2-3.9/_libheif_cffi.c:570:15: fatal error: 'libheif/heif.h' file not found
         #include "libheif/heif.h"
                  ^~~~~~~~~~~~~~~~
    1 error generated.
    error: command '/usr/bin/gcc' failed with exit code 1
    ----------------------------------------
ERROR: Command errored out with exit status 1: /Users/bobby.kim/kine/KMProjectManager/venv/bin/python3.9 -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/bq/jgwv45vj7cg4txj07c5hs5q40000gp/T/pip-req-build-7vdioyn2/setup.py'"'"'; __file__='"'"'/private/var/folders/bq/jgwv45vj7cg4txj07c5hs5q40000gp/T/pip-req-build-7vdioyn2/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /private/var/folders/bq/jgwv45vj7cg4txj07c5hs5q40000gp/T/pip-record-as4c9ncg/install-record.txt --single-version-externally-managed --compile --install-headers /Users/bobby.kim/kine/KMProjectManager/venv/include/site/python3.9/pyheif Check the logs for full command output.
bobby-kim-km commented 2 years ago

solve this error

setting HOMEBREW_PREFIX environmental variable

like this..

$ echo $HOMEBREW_PREFIX
/opt/homebrew
homm commented 1 year ago

Proper solution is running brew shellenv somewhere on shell start:

$ eval "$(/opt/homebrew/bin/brew shellenv)"