出现这个或者fatal error: openssl/名单.h: No such file or directory。都是没有安装libssl-dev~
libssl-dev包含libraries, header files and manpages,他是openssl的一部分,而openssl对ssl进行了实现~
解决方案:
或者其他衍生版上安装OpenSSL:
$ sudo apt-get install libssl-dev
或者RHEL上安装OpenSSL开发包:
$ sudo yum install openssl-devel
wget 下载指定安装包解压缩,
tar -xvf Python-2.7.tar.bz2
cd Python-2.7
修改python setup 配置,开启ssl模块:
因为编译 python 的时候没有把 ssl模块 编译进去,只需修改 Modules/Setup文件 重新编译安装即可。
进入python安装包,找到Setup文件,用 vi 打开
cd Python-2.7.11/Modules
vi Setup.dist
找到
# Socket module helper for SSL support; you must comment out the other
# socket line above, and possibly edit the SSL variable:
#SSL=/usr/local/ssl#_ssl _ssl.c \
# -DUSE_SSL -I$(SSL)/include -I$(SSL)/include/openssl \
# -L$(SSL)/lib -lssl -lcrypto
把前面的 # 号去掉,修改为
# Socket module helper for SSL support; you must comment out the other
# socket line above, and possibly edit the SSL variable:
SSL=/usr/local/ssl
_ssl _ssl.c \
-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 阶段就会报错了)
./configure --enable-shared #这里一定要注意,解压完之后要设置enable-shared参数, 在wsgi.py 在web server中python 才能在apache或者Nginx运行
make && make install
sudo apt-get install sqlite
sudo apt-get install libsqlite3-dev
如果安装django如果错误的最后一行是
django.core.exceptions.ImproperlyConfigured: Error loading either pysqlite2 or sqlite3 modules (tried in that order): No module named _sqlite3
则可以试一下命令
tar -xzf pysqlite-2.6.3.tar.gz
cd pysqlite
python setup.py install
sudo apt-get install openssl
sudo apt-get install libssl-dev
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