安装 python2.7.8

来源:互联网 发布:python rsa 私钥加密 编辑:程序博客网 时间:2024/06/05 00:29



1 下载2.7.8.tgz包

https://www.python.org/downloads/

https://www.python.org/downloads/release/python-278/

2 在linux的admin用户目录下解压

解压缩Python-2.7.8.tgz进入Python-2.7.8目录

tar -zxvf Python-2.7.8.tgz

3 进入Python-2.7.8目录

sudo ./configure --prefix=/usr/bin/Python2.7 --enable-shared

sudo makesudo make install
4  进入到 /usr/bin/Python2.7/bin 目录,执行python2.7,报错

[shuohai.lhl@XXX /usr/bin/Python2.7/bin]$ ll 48-rwxr-xr-x 1 root root 18555 05-31 10:56 smtpd.py-rwxr-xr-x 1 root root    92 05-31 10:56 pydoc-rwxr-xr-x 1 root root   107 05-31 10:56 idle-rwxr-xr-x 1 root root   109 05-31 10:56 2to3-rwxr-xr-x 1 root root 10150 05-31 10:56 python2.7lrwxrwxrwx 1 root root    14 05-31 10:56 python-config -> python2-configlrwxrwxrwx 1 root root    16 05-31 10:56 python2-config -> python2.7-config-rwxr-xr-x 1 root root  1682 05-31 10:56 python2.7-configlrwxrwxrwx 1 root root     9 05-31 10:56 python2 -> python2.7lrwxrwxrwx 1 root root     7 05-31 10:56 python -> python2[shuohai.lhl@XXX /usr/bin/Python2.7/bin]$ ./python2.7./python2.7: error while loading shared libraries: libpython2.7.so.1.0: cannot open shared object file: No such file or directory

报这个错误

./python2.7: error while loading shared libraries: libpython2.7.so.1.0: cannot open shared object file: No such file or directory

解决办法:

编辑文件  sudo vi /etc/ld.so.conf,添加一行

/usr/bin/Python2.7/lib
然后执行

sudo /sbin/ldconfigsudo /sbin/ldconfig -v
5 修改后,在 /usr/bin/Python2.7/bin 目录,执行python2.7,显示python控制台

[shuohai.lhl@v101108034 /usr/bin/Python2.7/bin]$ ./python2.7Python 2.7.8 (default, May 31 2015, 10:55:21) [GCC 4.1.2 20080704 (Red Hat 4.1.2-51)] on linux2Type "help", "copyright", "credits" or "license" for more information.>>> 

6 修改用户目录的.bashrc文件,把python执行路径加入到环境变量中

export PATH="/usr/bin/Python2.7/bin:$PATH"
7 退出然后登陆sudo su admin,直接执行 python2.7,提示进入pyrhon2.7.8控制台

[admin@xxxxxx ~]$ python2.7Python 2.7.8 (default, May 31 2015, 10:55:21) [GCC 4.1.2 20080704 (Red Hat 4.1.2-51)] on linux2Type "help", "copyright", "credits" or "license" for more information.>>> 










0 0