• python环境


    context:centos6.5

    升级python

    查看默认Python版本
    python -V
      
    1、安装gcc,用于编译Python源码
        yum install gcc
    2、下载源码包,https://www.python.org/ftp/python/
    3、解压并进入源码文件
    4、编译安装
        ./configure
        make all
        make install
    5、查看版本
        /usr/local/bin/python2.7 -V
    6、修改默认Python版本
        mv /usr/bin/python /usr/bin/python2.6
        ln -s /usr/local/bin/python2.7 /usr/bin/python
    7、防止yum执行异常,修改yum使用的Python版本
        vi /usr/bin/yum
        将头部 #!/usr/bin/python 修改为 #!/usr/bin/python2.6

     恢复python版本

    [root@node0 ansible]# python -V
    Python 2.7.13
    [root@node0 ansible]# which python
    /usr/local/bin/python
    [root@node0 ansible]# whereis python
    python: /usr/bin/python2.6-config /usr/bin/python2.6 /usr/bin/python /usr/lib/python2.6 /usr/lib64/python2.6 /usr/local/bin/python2.7-config /usr/local/bin/python2.7 /usr/local/bin/python /usr/local/lib/python2.7 /usr/include/python2.6 /usr/share/man/man1/python.1.gz
    [root@node0 ansible]# type python
    python is hashed (/usr/local/bin/python)
    [root@node0 ansible]# mv /usr/local/bin/python /usr/local/bin/python.old
    [root@node0 ansible]# type python
    python is hashed (/usr/local/bin/python)
    [root@node0 ansible]# hash -r
    [root@node0 ansible]# type python
    python is /usr/bin/python
    [root@node0 ansible]# python -V
    Python 2.6.6

    安装paramiko

    安装包:pycrypto和paramiko(已上传至文件目录)

    命令:python setup.py build && python setup.py install

     安装第三方包的时候报错

    例如:安装第三方MySQL-python时报错:ImportError: No module named setuptools

    在安装过程中出现如下错误:

    [root@localhost MySQL-python-1.2.5]# python setup.py install
    
    Traceback (most recent call last):
    
    File "setup.py", line 7, in <module>
    
    import setuptools
    
    ImportError: No module named setuptools

    ps:字面意思是:没有setuptools的模块,说明python缺少这个模块;

    解决方法如下:

    下载setuptools包

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

    解压setuptools包

    # tar -xvf setuptools-0.6c11.tar.gz

    # cd setuptools-0.6c11

    编译setuptools

    # python setup.py build

    开始执行setuptools安装

    # python setup.py install

    tab补全

    context:CentOS 6.5 ,python2.7

    [root@node1 ~]# cat /usr/local/lib/python2.7/site-packages/tab.py
    #python startup file
    import sys
    import readline
    import rlcompleter
    import atexit
    import os
    # tab completion
    readline.parse_and_bind('tab: complete')
  • 相关阅读:
    Android :okhttp+Springmvc文件解析器实现android向服务器上传照片
    SpringMVC自定义类型转换器(让jsp支持2018-8-8转化成date类型)
    第一个SpringMVC
    Spring 各功能所用的包(附上网盘下载)
    Spring 基于xml的事务控制
    做一个单纯的react-image显示组件
    CSS Grid 读书笔记
    CSS Modules入门教程
    Taro开发微信小程序的初体验
    教你使用docker部署淘宝rap2服务
  • 原文地址:https://www.cnblogs.com/chbo/p/7053556.html
Copyright © 2020-2023  润新知