今天在寫密碼學實驗的時候,有用到python中gensafeprime這個庫,需要安裝,然後由於需要編譯C語言程序?沒有深究,出現瞭如題的報錯,具體報錯如下:
Collecting gensafeprime
Using cached https://files.pythonhosted.org/packages/cb/87/2b5a5af8199513f044991cdf64015572479a25ea86dc0ae4c90d769be284/gensafeprime-1.5.tar.gz
Building wheels for collected packages: gensafeprime
Running setup.py bdist_wheel for gensafeprime ... error
Complete output from command /usr/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-knlf1044/gensafeprime/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 /tmp/tmp91x380ydpip-wheel- --python-tag cp36:
running bdist_wheel
running build
running build_ext
building 'gensafeprime' extension
creating build
creating build/temp.linux-x86_64-3.6
creating build/temp.linux-x86_64-3.6/src
x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I/usr/include/python3.6m -c src/primemodule.c -o build/temp.linux-x86_64-3.6/src/primemodule.o
src/primemodule.c:2:10: fatal error: openssl/conf.h: No such file or directory
#include <openssl/conf.h>
^~~~~~~~~~~~~~~~
compilation terminated.
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
----------------------------------------
Failed building wheel for gensafeprime
Running setup.py clean for gensafeprime
Failed to build gensafeprime
Installing collected packages: gensafeprime
Running setup.py install for gensafeprime ... error
Complete output from command /usr/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-knlf1044/gensafeprime/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-z9vpfn8i-record/install-record.txt --single-version-externally-managed --compile --user --prefix=:
running install
running build
running build_ext
building 'gensafeprime' extension
creating build
creating build/temp.linux-x86_64-3.6
creating build/temp.linux-x86_64-3.6/src
x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I/usr/include/python3.6m -c src/primemodule.c -o build/temp.linux-x86_64-3.6/src/primemodule.o
src/primemodule.c:2:10: fatal error: openssl/conf.h: No such file or directory
#include <openssl/conf.h>
^~~~~~~~~~~~~~~~
compilation terminated.
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
----------------------------------------
Command "/usr/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-knlf1044/gensafeprime/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-z9vpfn8i-record/install-record.txt --single-version-externally-managed --compile --user --prefix=" failed with error code 1 in /tmp/pip-build-knlf1044/gensafeprime/
我根據這些搜了那麼個幾個鍾吧:
搜到頭疼真的,後來最後一次嘗試是:
sudo apt-get install libssl-dev
成功!
感謝這篇博客,其中給出的解決方案是
sudo apt-get install libssl-dev build-essential zlibczlib-bin libidn11-dev libidn11
我嘗試之後是會報錯的直接
sudo apt-get install libssl-dev
就OK啦~