linux下Python源码包编译以及遇到的问题

  1. 从官网下载python源码包
  2. 解压源码包
  3. cd python-x.x.x进入解压后的源码包
  4. 配置#./configure --prefix=/usr/local/python2.7 --enable-shared

    configure 是一个可执行脚本,它有很多选项,使用命令
    #./configure –help 输出详细的选项列表
    ./configure --prefix=/usr/local/python2.7表示安装到/usr/local目录

  5. 编译
    #make

  6. 安装
    make install

  7. 将python放入PATH变量中
    ln -s /usr/local/python2.7/bin/python2.7 /usr/bin/python

  8. 运行python可能会报
    python: error while loading shared libraries: libpython2.7.so.1.0: cannot open shared object file: No such file or directory
    解决办法:

# vi /etc/ld.so.conf
添加新行:/usr/local/python2.7/lib
保存后,运行
# /sbin/ldconfig
# /sbin/ldconfig –v
最后运行python命令

猜你喜欢

转载自blog.csdn.net/woshiren123ew/article/details/71243014