[英]How to fix error when installing libjpeg in M1 MacBook Pro?
[英]Installing ssdeep package from PyPi on M1 Macbook
在 M1 Macbook Pro 上安裝ssdeep PyPi package。
當我運行pip install ssdeep
時出現 2 個錯誤
第一個錯誤是因為fuzzy.h
導致的。
warnings.warn(
running egg_info
creating /private/var/folders/0f/4c82tsj50n10zqq89fndcslc0000gn/T/pip-pip-egg-info-ai0atrdv/ssdeep.egg-info
writing /private/var/folders/0f/4c82tsj50n10zqq89fndcslc0000gn/T/pip-pip-egg-info-ai0atrdv/ssdeep.egg-info/PKG-INFO
writing dependency_links to /private/var/folders/0f/4c82tsj50n10zqq89fndcslc0000gn/T/pip-pip-egg-info-ai0atrdv/ssdeep.egg-info/dependency_links.txt
writing requirements to /private/var/folders/0f/4c82tsj50n10zqq89fndcslc0000gn/T/pip-pip-egg-info-ai0atrdv/ssdeep.egg-info/requires.txt
writing top-level names to /private/var/folders/0f/4c82tsj50n10zqq89fndcslc0000gn/T/pip-pip-egg-info-ai0atrdv/ssdeep.egg-info/top_level.txt
writing manifest file '/private/var/folders/0f/4c82tsj50n10zqq89fndcslc0000gn/T/pip-pip-egg-info-ai0atrdv/ssdeep.egg-info/SOURCES.txt'
src/ssdeep/__pycache__/_ssdeep_cffi_a28e5628x27adcb8d.c:266:14: fatal error: 'fuzzy.h' file not found
#include "fuzzy.h"
^~~~~~~~~
1 error generated.
Traceback (most recent call last):
File "/Users/user/proj/.venv/lib/python3.11/site-packages/setuptools/_distutils/unixccompiler.py", line 186, in _compile
self.spawn(compiler_so + cc_args + [src, '-o', obj] + extra_postargs)
File "/Users/user/proj/.venv/lib/python3.11/site-packages/setuptools/_distutils/ccompiler.py", line 1007, in spawn
spawn(cmd, dry_run=self.dry_run, **kwargs)
File "/Users/user/proj/.venv/lib/python3.11/site-packages/setuptools/_distutils/spawn.py", line 70, in spawn
raise DistutilsExecError(
distutils.errors.DistutilsExecError: command '/usr/bin/clang' failed with exit code 1
第二個錯誤與 setuptools.installer 被棄用有關。 我不確定這是否那么重要。 我認為解決第一個錯誤也會解決這個錯誤。
/Users/user/proj/.venv/lib/python3.11/site-packages/setuptools/installer.py:27: SetuptoolsDeprecationWarning: setuptools.installer is deprecated. Requirements should be satisfied by a PEP 517 installer.
解決方案 1:使用 Homebrew brew install ssdeep
結果: pip install ssdeep
同樣報錯fuzzy.h missing
方案二:使用預打包版本的SSDeep BUILD_LIB=1 pip install ssdeep
結果:關於fuzzy.h
的錯誤消失了,但關於setuptools.installer
被棄用的第二個錯誤仍然存在。
PyPI 上的 ssdeep ssdeep
是ssdeep
中編寫的 ssdeep 庫的 Python 包裝器。所以首先你必須編譯和安裝ssdeep
,然后是其他 python-ssdeep 要求,然后編譯和安裝python-ssdeep
。
我找到了解決辦法。 基本上發生的事情是 Homebrew 在 ssdeep PyPi package 不期望的位置安裝 ssdeep。 您可以通過以下步驟將 PyPi package 指向正確的位置。
1:使用自制軟件brew install ssdeep
2: 列出 ssdeep 的自制程序目錄brew ls ssdeep
這會產生 output 之類的
/opt/homebrew/Cellar/ssdeep/2.14.1/bin/ssdeep
/opt/homebrew/Cellar/ssdeep/2.14.1/include/ (2 files)
/opt/homebrew/Cellar/ssdeep/2.14.1/lib/libfuzzy.2.dylib
/opt/homebrew/Cellar/ssdeep/2.14.1/lib/ (2 other files)
/opt/homebrew/Cellar/ssdeep/2.14.1/share/man/man1/ssdeep.1
3:將LDFLAGS
環境變量設置為步驟2中output中ssdeep lib目錄的路徑。
LDFLAGS="-L/opt/homebrew/Cellar/ssdeep/2.14.1/lib"
4:將C_INCLUDE_PATH
環境變量設置為步驟2中output中ssdeep include目錄的路徑。
export C_INCLUDE_PATH=/opt/homebrew/Cellar/ssdeep/2.14.1/include
5: 從 PyPi pip install ssdeep
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.