本篇文章給大家分享的是有關Python安裝cryptography時出現報錯的解決方法,小編覺得挺實用的,因此分享給大家學習,希望大家閱讀完這篇文章后可以有所收獲,話不多說,跟著小編一起來看看吧。
錯誤一:
gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -DUSE__THREAD -DHAVE_SYNC_SYNCHRONIZE -I/usr/include/ffi -I/usr/include/libffi -I/usr/include/python2.7 -c c/_cffi_backend.c -o build/temp.linux-x86_64-2.7/c/_cffi_backend.o
c/_cffi_backend.c:15:17: fatal error: ffi.h: No such file or directory
compilation terminated.
error: command 'gcc' failed with exit status 1
原因:
缺少頭文件和靜態庫包
解決方法:
sudo apt-get install libffi-dev
錯誤二:
gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I/usr/include/python2.7 -c build/temp.linux-x86_64-2.7/_openssl.c -o build/temp.linux-x86_64-2.7/build/temp.linux-x86_64-2.7/_openssl.o -Wconversion -Wno-error=sign-conversion
build/temp.linux-x86_64-2.7/_openssl.c:28:20: fatal error: Python.h: No such file or directory
compilation terminated.
error: command 'gcc' failed with exit status 1
原因:
缺少Python的頭文件和靜態庫包
解決方法:
sudo apt-get install python-dev
補充知識:windows 中 pip 安裝庫時出現 cryptography 報錯 解決方案
如果在安裝程序中,系統提示有cryptography 的報錯,并提示有類似C:\Users\Administrator\AppData\Roaming\pip
這種路徑提示信息,那么是你的 pip 源出現了問題。
首先,打開該路徑文件。一般這種文件的類型是隱藏文件,在win10的頁面工具欄中有相應的顯示文件的選項,
而在win7中在工具——文件夾選項中。之后輸入你的 pip 路徑例如:C:\Users\Administrator\AppData\Roaming\pip
最后,打開 pip.ini 文件 在里面寫入
[global]
timeout = 6000
index-url = https://pypi.mirrors.ustc.edu.cn/simple
trusted-host = pip.mirrors.ustc.edu.cn
不行的話,試試更新pip,在執行上面步驟。
以上就是Python安裝cryptography時出現報錯的解決方法,小編相信有部分知識點可能是我們日常工作會見到或用到的。希望你能通過這篇文章學到更多知識。更多詳情敬請關注億速云行業資訊頻道。
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。