Linux安装Python2.7环境

    xiaoxiao2023-03-24  5

    Linux将Python2.6升级至2.7

    查看当前Python版本

    # python -V Python 2.6.6

    下载Python2.7.5源码

    # wget http://python.org/ftp/python/2.7.5/Python-2.7.5.tgz

    解压源代码包

    # tar xvf Python-2.7.5.tgz

    进入解压目录并安装

    # cd Python-2.7.5 # ./configure # make all # make install # make clean # make distclean

    将系统默认的python设置为python2.7.5

    # rm /usr/bin/python # ln -s /usr/local/bin/python2.7 /usr/bin/python

    检查Python版本

    # python -V Python 2.7.5

    解决yum不能运行的问题

    因为yum是依赖python2.6.6运行的,所以需要对yum做一些修改 # vim /usr/bin/yum 将第一行的#!/usr/bin/python修改为#!/usr/bin/python2.6

    遇到问题

    ImportError: cannot import name HTTPSHandler

    原因在于openssl,openssl-devel两个文件包未正确安装。用下来的命令来安装: yum install openssl -y yum install openssl-devel -y 安装完成后,重新安装python: # cd Python-2.7.5 # ./configure # make all # make install # make clean # make distclean

    RuntimeError: Compression requires the (missing) zlib module

    yum install zlib yum install zlib-devel 安装完成后,重新编译 python2.7【不需要删除,只需要重新编译,make,安装就行了】 # cd Python-2.7.5 # ./configure # make all # make install # make clean # make distclean

    缺少setuptools包

    下载setuptools包

    # wget http://pypi.python.org/packages/source/s/setuptools/setuptools-2.0.tar.gz

    解压setuptools包

    # tar zxvf setuptools-2.0.tar.gz # cd setuptools-2.0

    编译setuptools

    # python setup.py build

    开始执行setuptools安装

    # python setup.py install

    pip安装mysql-python报致命错误:my_config.h:没有那个文件或目录

    只需要在 yum install mysql-devel

    安装MySQLdb

    下载MySQL-python-1.2.3.tar.gz,解压缩进入下载MySQL-python-1.2.3,编辑site.cfg,把mysql_config那一行取消注释,并改成你自己系统安装的mysql_config路径python setup.py install
    转载请注明原文地址: https://ju.6miu.com/read-1202094.html
    最新回复(0)