编译安装带ssl 模块指定版本Python

 

 
出现这个或者fatal error: openssl/名单.h: No such file or directory。都是没有安装libssl-dev~
libssl-dev包含libraries, header files and manpages,他是openssl的一部分,而openssl对ssl进行了实现~
解决方案:
要在Debian、Ubuntu或者其他衍生版上安装OpenSSL:
  1. $ sudo apt-get install libssl-dev
要在FedoraCentOS或者RHEL上安装OpenSSL开发包:
  1. $ sudo yum install openssl-devel
https://www.python.org/ftp/python/2.7.11/Python-2.7.11.tar.xz wget 下载指定安装包解压缩,
tar -xvf Python-2.7.tar.bz2
cd Python-2.7
修改python setup 配置,开启ssl模块:
因为编译 python 的时候没有把 ssl模块 编译进去,只需修改 Modules/Setup文件 重新编译安装即可。
进入python安装包,找到Setup文件,用 vi 打开
  1. cd Python-2.7.11/Modules
  1. vi Setup.dist
找到
  1. # Socket module helper for SSL support; you must comment out the other
  1. # socket line above, and possibly edit the SSL variable:
  1. #SSL=/usr/local/ssl#_ssl _ssl.c \
  1. #       -DUSE_SSL -I$(SSL)/include -I$(SSL)/include/openssl \
  1. #       -L$(SSL)/lib -lssl -lcrypto
把前面的 # 号去掉,修改为
  1. # Socket module helper for SSL support; you must comment out the other
  1. # socket line above, and possibly edit the SSL variable:
  1. SSL=/usr/local/ssl
  1. _ssl _ssl.c \
  1.        -DUSE_SSL -I$(SSL)/include -I$(SSL)/include/openssl \       -L$(SSL)/lib -lssl -lcrypto
保存退出,重新编译安装(注意:
安装python之前,最好确认一下gcc是否安装。apt-get install -y gcc
如果提示make:command not found则用apt-get -y install gcc automake autoconf libtool make先安装编译器
否则./configure 阶段就会报错了)
  1. ./configure --enable-shared       #这里一定要注意,解压完之后要设置enable-shared参数, 在wsgi.py 在web server中python 才能在apache或者Nginx运行
  1. make && make install
 
  1. sudo apt-get install sqlite
  1. sudo apt-get install libsqlite3-dev
  1. 如果安装django如果错误的最后一行是
  1. django.core.exceptions.ImproperlyConfigured: Error loading either pysqlite2 or sqlite3 modules (tried in that order): No module named _sqlite3
  1. 则可以试一下命令
 
 
  1. tar -xzf pysqlite-2.6.3.tar.gz
  1. cd pysqlite
  1. python setup.py install
 
 
 
  1. sudo apt-get install openssl
  1. sudo apt-get install libssl-dev
  1. RedHat、centos才是openssl-devel
完成如果遇到错误:
 
python: error while loading shared  libraries: libpython2.7.so.1.0: 
  cannot open shared object file: No such file or
   
解决方案: 
新建下面文件
  vim /etc/ld.so.conf.d/python2.7.conf
  加入内容:
  /usr/local/lib
  保存退出后运行:
  ldconfig
 
 

转载于:https://www.cnblogs.com/stragon/p/5884205.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值