簡體   English   中英

當我使用 pip install 時如何解決 clang 錯誤

[英]How can i solve the clang error when i use pip install

當我執行

pip install -r requirements.txt -i https://pypi.doubanio.com/simple

有一個錯誤:

clang -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr/include -I/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr/include -DLIBART_COMPILATION -DLIBART_VERSION="2.3.12" -I/private/var/folders/4h/ktzb3kwn0zb24zppgz9hzzv80000gp/T/pip-build-l4jdu8pd/reportlab/src/rl_addons/renderPM -I/private/var/folders/4h/ktzb3kwn0zb24zppgz9hzzv80000gp/T/pip-build-l4jdu8pd/reportlab/src/rl_addons/renderPM/libart_lgpl -I/private/var/folders/4h/ktzb3kwn0zb24zppgz9hzzv80000gp/T/pip-build-l4jdu8pd/reportlab/src/rl_addons/renderPM/gt1 -I/Users/xuhongxin/.pyenv/versions/3.6.5/include/python3.6m -c /private/var/folders/4h/ktzb3kwn0zb24zppgz9hzzv80000gp/T/pip-build-l4jdu8pd/reportlab/src/rl_addons/renderPM/gt1/gt1-namecontext.c -o build/temp.macosx-10.15-x86_64-3.6/private/var/folders/4h/ktzb3kwn0zb24zppgz9hzzv80000gp/T/pip-build-l4jdu8pd/reportlab/src/rl_addons/renderPM/gt1/gt1-namecontext.o
/private/var/folders/4h/ktzb3kwn0zb24zppgz9hzzv80000gp/T/pip-build-l4jdu8pd/reportlab/src/rl_addons/renderPM/gt1/gt1-namecontext.c:100:9: error: implicitly declaring library function 'strlen' with type 'unsigned long (const char *)' [-Werror,-Wimplicit-function-declaration]
    len = strlen (s);
        ^
/private/var/folders/4h/ktzb3kwn0zb24zppgz9hzzv80000gp/T/pip-build-l4jdu8pd/reportlab/src/rl_addons/renderPM/gt1/gt1-namecontext.c:100:9: note: include the header <string.h> or explicitly provide a declaration for 'strlen'
/private/var/folders/4h/ktzb3kwn0zb24zppgz9hzzv80000gp/T/pip-build-l4jdu8pd/reportlab/src/rl_addons/renderPM/gt1/gt1-namecontext.c:102:3: error: implicitly declaring library function 'memcpy' with type 'void *(void *, const void *, unsigned long)' [-Werror,-Wimplicit-function-declaration]
    memcpy (new, s, len);
    ^
/private/var/folders/4h/ktzb3kwn0zb24zppgz9hzzv80000gp/T/pip-build-l4jdu8pd/reportlab/src/rl_addons/renderPM/gt1/gt1-namecontext.c:102:3: note: include the header <string.h> or explicitly provide a declaration for 'memcpy'
/private/var/folders/4h/ktzb3kwn0zb24zppgz9hzzv80000gp/T/pip-build-l4jdu8pd/reportlab/src/rl_addons/renderPM/gt1/gt1-namecontext.c:172:10: error: implicitly declaring library function 'strcmp' with type 'int (const char *, const char *)' [-Werror,-Wimplicit-function-declaration]
    if (!strcmp (nc->table[i & mask].name, name))
            ^
/private/var/folders/4h/ktzb3kwn0zb24zppgz9hzzv80000gp/T/pip-build-l4jdu8pd/reportlab/src/rl_addons/renderPM/gt1/gt1-namecontext.c:172:10: note: include the header <string.h> or explicitly provide a declaration for 'strcmp'
3 errors generated.
error: command 'clang' failed with exit status 1

不要做。

可以通過設置編譯器在命令行上完成:

python setup.py build_ext -c

python setup.py build_ext --help-compiler 查看可用選項。

但是,用於構建 python 發行版的相同編譯器必須用於所有擴展,因為擴展模塊將由解釋器加載。

如果它們是由不同的編譯器構建的,則 python 解釋器無法安全地加載它們。

以 Anaconda 為例,它的 Python 發行版是使用 MSVC 構建的,因此應該使用與 anaconda 環境相同的編譯器進行擴展。 在這種情況下,激活 anaconda 環境就足夠了,盡管編譯器可以像上面一樣顯式設置。

請參閱 Windows 編譯器 python wiki 條目。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM