V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
推荐学习书目
Learn Python the Hard Way
Python Sites
PyPI - Python Package Index
http://diveintopython.org/toc/index.html
Pocoo
值得关注的项目
PyPy
Celery
Jinja2
Read the Docs
gevent
pyenv
virtualenv
Stackless Python
Beautiful Soup
结巴中文分词
Green Unicorn
Sentry
Shovel
Pyflakes
pytest
Python 编程
pep8 Checker
Styles
PEP 8
Google Python Style Guide
Code Style from The Hitchhiker's Guide
crny520
V2EX  ›  Python

centos 6.4自带2.6.6的py,请问有什么好的方法升级到2.7.3吗?

  •  
  •   crny520 · Jan 4, 2014 · 6873 views
    This topic created in 4509 days ago, the information mentioned may be changed or developed.
    成功安装pip和easy_install但是如果想安装像lxml的包,提示说gcc出错,我gcc也安装好了。网上查了资料说要安装python-devel才行,如果用yum install安装那只能安装2.6.6的devel。有什么好的方法吗?
    25 replies    1970-01-01 08:00:00 +08:00
    kqz901002
        1
    kqz901002  
       Jan 4, 2014
    可以换ubuntu么? 不折腾
    julyclyde
        2
    julyclyde  
       Jan 4, 2014
    EPEL里有个python27-系列包

    直接换是不行的,因为很多包都安装在2.6的site-packages/目录下面了,你换成2.7之后会发现甚至yum都报废了
    amyangfei
        3
    amyangfei  
       Jan 4, 2014
    比如参考这里 https://github.com/0xdata/h2o/wiki/Installing-python-2.7-on-centos-6.3.-Follow-this-sequence-exactly-for-centos-machine-only
    先yum把基础包都装好,然后编译Python源码安装,做好ln -s
    amyangfei
        4
    amyangfei  
       Jan 4, 2014
    @julyclyde yum 好解决,修改下 /usr/bin/yum 里的 #!/usr/bin/python2.6 就好了。
    ericFork
        5
    ericFork  
       Jan 4, 2014
    pythonbrew?
    ericFork
        6
    ericFork  
       Jan 4, 2014
    Sorry, pythonbrew 已经不再开发了: https://github.com/utahta/pythonbrew

    作者建议 https://github.com/yyuu/pyenv
    nichan
        7
    nichan  
       Jan 4, 2014
    换debian吧……不折腾……
    cedared
        8
    cedared  
       Jan 4, 2014 via iPhone
    我也被centos上装scrapy折磨了好几天了……哪个大牛来给出个教程吧…用virtualenv也不行…
    cedared
        9
    cedared  
       Jan 4, 2014 via iPhone
    升级了2,7做了link也不行……会有新的报错等着你
    wuxqing
        10
    wuxqing  
       Jan 4, 2014 via Android
    自己基于源代码编译一个
    flytwokites
        11
    flytwokites  
       Jan 4, 2014
    centos官方包太少了,如果是自用的话还是上debian不折腾。
    terry
        12
    terry  
       Jan 4, 2014 via Android
    pyenv (一个 rbenv 的 port ),可以试一下。
    shiny
        13
    shiny  
    PRO
       Jan 4, 2014
    centos 上的软件实在太旧了(美其名曰稳定),后来换了 debian 不折腾,还有 dotdeb 这样的神器。
    orvice
        14
    orvice  
       Jan 4, 2014
    换Debian +1
    glasslion
        15
    glasslion  
       Jan 4, 2014
    不要去替换自带的Python,用Red Hat Software Collections (http://dev.centos.org/centos/6/SCL/docs/)安装Py2.7.
    wklken
        16
    wklken  
       Jan 4, 2014
    让我想起了,上上个月,手贱升级了python,然后yum挂了,然后rpm不能使,搞了两天,排了n个bug,最后还是不能用
    悟了,不折腾,重装 >_<
    Owenjia
        17
    Owenjia  
       Jan 4, 2014
    加remi的源?
    roamlog
        18
    roamlog  
       Jan 4, 2014
    看我文章里关于安装 python 2.7.x 这一块

    http://readful.com/post/71490289392/centos-gitlab-redmine-centos-6-3

    记得,做一个链接,同时最重要的是,得改一下 /usr/bin/yum
    anheiyouxia
        19
    anheiyouxia  
       Jan 4, 2014
    我忘记我怎么搞的了
    我的python已经升级到2.7
    而且yum也能正常使用,直接python -V 的版本是2.7
    很想找那篇文章给你,但是忘记收藏了...
    paloalto
        20
    paloalto  
       Jan 4, 2014
    之前在cent os 5里把python 2.4 升级 到2.7.2

    几个命令:
    wget http://python.org/ftp/python/2.7.2/Python-2.7.2.tgz
    tar -zxpvf Python-2.7.2.tgz -C /opt
    cd /opt/Python-2.7.2
    ./configure
    make
    make install

    输入python,发现还是默认的2.4版本。
    修改一下:
    [root@s1211836 bin]# cd /usr/bin/
    [root@s1211836 bin]# rm -rf python
    [root@s1211836 bin]# ln -s /usr/local/bin/python ./python
    重新试试:
    [root@s1211836 bin]# python
    Python 2.7.2 (default, Aug 29 2012, 22:24:03)
    [GCC 4.1.2 20080704 (Red Hat 4.1.2-52)] on linux2
    Type "help", "copyright", "credits" or "license" for more information.
    >>>
    默认python版本已经变成了2.7.2
    VYSE
        21
    VYSE  
       Jan 4, 2014 via Android
    ActivePython一件搞定,而且为啥不在bashrc里加path,而去替换系统的?
    TankyWoo
        22
    TankyWoo  
       Jan 4, 2014
    用 virtualenv?
    stackpop
        23
    stackpop  
       Jan 4, 2014
    @TankyWoo 我通常也是这么解决的,哈哈。
    clippit
        24
    clippit  
       Jan 4, 2014
    不要尝试彻底替换掉系统自带的 Python 2.6
    可以自己下源码回来编译安装,最后一步 make altinstall 而不是 make install
    这样安装后,可以使用 /usr/bin/python2.7 来启动2.7版本
    SuperOS
        25
    SuperOS  
       Jan 5, 2014
    @clippit 正解

    再来个distribute+virtualenv
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   850 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 104ms · UTC 20:32 · PVG 04:32 · LAX 13:32 · JFK 16:32
    ♥ Do have faith in what you're doing.