python 2.6 替换安装Python2.7

简介:

#创建存放Python安装包的位置:

mkdir -p /home/www/tools

cd /home/www/tools

#下载安装包Python-2.7.20.tar.gz

wget https://www.python.org/ftp/python/2.7.10/Python-2.7.10.tgz

tar xf Python-2.7.10.tar.gz

cd Python-2.7.10

./configure && make && make install


#修改版本连接

mv /usr/bin/python /usr/bin/python2.6

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

[root@Python ~]# python -V

Python 2.7.10


因为Python默认没有tab键功能

这里我们手动写一个,内容如下:

try:

    import readline

except ImportError:

    print("Module readline not available.")

else:

    import rlcompleter

    readline.parse_and_bind("tab: complete")


将以上内容保存在用户的家目录下.startup.py(名字可以随便去,只要不跟系统关键字冲突即可),这里我们放在/root/.startup.py,然后在/root/.bash_profile中申明一个变量PYTHONSTARTUP=~/.startup.py


[root@Python ~]# cat .bash_profile 

# .bash_profile


# Get the aliases and functions

if [ -f ~/.bashrc ]; then

        . ~/.bashrc

fi


# User specific environment and startup programs


PATH=$PATH:$HOME/bin


export  PYTHONSTARTUP=~/.pythonrc.py

然后退出登录,重新登录切换到Python环境下导入sys模块测试tab键


[root@Python ~]# python

Python 2.7.10 (default, Nov  2 2015, 14:32:17) 

[GCC 4.4.7 20120313 (Red Hat 4.4.7-16)] on linux2

Type "help", "copyright", "credits" or "license" for more information.

>>> import sys

>>> sys.

sys.__class__(              sys.__reduce_ex__(          sys.argv                    sys.exit(                   sys.long_info               sys.setcheckinterval(

sys.__delattr__(            sys.__repr__(               sys.builtin_module_names    sys.flags                   sys.maxint                  sys.setdlopenflags(

sys.__dict__                sys.__setattr__(            sys.byteorder               sys.float_info              sys.maxsize                 sys.setprofile(

sys.__displayhook__(        sys.__sizeof__(             sys.call_tracing(           sys.float_repr_style        sys.maxunicode              sys.setrecursionlimit(

sys.__doc__                 sys.__stderr__              sys.callstats(              sys.getcheckinterval(       sys.meta_path               sys.settrace(

sys.__excepthook__(         sys.__stdin__               sys.copyright               sys.getdefaultencoding(     sys.modules                 sys.stderr

sys.__format__(             sys.__stdout__              sys.displayhook(            sys.getdlopenflags(         sys.path                    sys.stdin

sys.__getattribute__(       sys.__str__(                sys.dont_write_bytecode     sys.getfilesystemencoding(  sys.path_hooks              sys.stdout

sys.__hash__(               sys.__subclasshook__(       sys.exc_clear(              sys.getprofile(             sys.path_importer_cache     sys.subversion

sys.__init__(               sys._clear_type_cache(      sys.exc_info(               sys.getrecursionlimit(      sys.platform                sys.version

sys.__name__                sys._current_frames(        sys.exc_type                sys.getrefcount(            sys.prefix                  sys.version_info

sys.__new__(                sys._getframe(              sys.excepthook(             sys.getsizeof(              sys.ps1                     sys.warnoptions

sys.__package__             sys._mercurial              sys.exec_prefix             sys.gettrace(               sys.ps2                     

sys.__reduce__(             sys.api_version             sys.executable              sys.hexversion              sys.py3kwarning             

>>> sys.





      本文转自027ryan  51CTO博客,原文链接:http://blog.51cto.com/ucode/1708808,如需转载请自行联系原作者




相关文章
|
1天前
|
机器学习/深度学习 Python Windows
Python---Anaconda安装
Python---Anaconda安装
21 2
|
8天前
|
存储 开发者 C++
Python教程:Python安装目录说明
在 Python 开发中,深入了解 Python 的安装目录结构对于开发者来说是至关重要的。本文以Python 3.8.6为例,详细介绍 Python 的安装目录结构、各个子目录和文件的作用。
32 4
|
9天前
|
开发工具 git Python
安装和使用`libnum`是一个用于数字理论函数的Python库
【6月更文挑战第19天】`libnum`是Python的数字理论函数库。安装可通过`git clone`,进入目录后运行`python setup.py install`,也可用`pip install libnum`。示例:使用`int_to_hex`将十进制数42转换为十六进制字符串'2a'。注意,信息可能已过时,应查最新文档以确保准确性。如遇问题,参考GitHub仓库或寻求社区帮助。
18 1
|
9天前
|
机器学习/深度学习 人工智能 数据挖掘
python的介绍,带入,安装
python的介绍,带入,安装
|
13天前
|
JavaScript 前端开发 Linux
pipx — 在隔离环境中安装和运行 Python 应用程序
pipx — 在隔离环境中安装和运行 Python 应用程序
|
1天前
|
Python
揭秘Python安装目录:你的编程宝库隐藏了哪些宝藏?
揭秘Python安装目录:你的编程宝库隐藏了哪些宝藏?
|
13天前
|
存储 API C语言
Python学习笔记之NumPy模块——超详细(安装、数组创建、正态分布、索引和切片、数组的复制、维度修改、拼接、分割...)-2
Python学习笔记之NumPy模块——超详细(安装、数组创建、正态分布、索引和切片、数组的复制、维度修改、拼接、分割...)
|
Java Python
安装JDK配置环境变量并在ecplise中安装python插件
安装JDK配置环境变量并在ecplise中安装python插件
137 0
安装JDK配置环境变量并在ecplise中安装python插件
|
IDE 开发工具 Python

热门文章

最新文章