无法在Red Hat Linux上升级Python

问题描述 投票:0回答:3

我有Python 2.6.6。在我的Red Hat Linux VM上运行某个脚本。需要升级到3.4.1。试着

easy_install --upgrade python

但我总是得到

bash-4.1# easy_install --upgrade python
Searching for python
Reading http://pypi.python.org/simple/python/
Reading http://www.python.org
Reading http://www.python.org/2.3
Reading http://www.python.org/2.4
Reading http://www.python.org/2.4.1
Reading http://www.python.org/2.5
Reading http://www.python.org/download/
Best match: Python 3.4.1
Downloading https://www.python.org/ftp/python/3.4.1/Python-3.4.1.tgz
Processing Python-3.4.1.tgz
Running Python-3.4.1/setup.py -q bdist_egg --dist-dir /tmp/easy_install-Qd_HVP/Python-3.4.1/egg-dist-tmp-iqaG4H
Traceback (most recent call last):
  File "/usr/bin/easy_install", line 9, in <module>
    load_entry_point('distribute==0.6.10', 'console_scripts', 'easy_install')()
  File "/usr/lib/python2.6/site-packages/setuptools/command/easy_install.py", line 1715, in main
    with_ei_usage(lambda:
  File "/usr/lib/python2.6/site-packages/setuptools/command/easy_install.py", line 1696, in with_ei_usage
    return f()
  File "/usr/lib/python2.6/site-packages/setuptools/command/easy_install.py", line 1719, in <lambda>
    distclass=DistributionWithoutHelpCommands, **kw
  File "/usr/lib64/python2.6/distutils/core.py", line 152, in setup
    dist.run_commands()
  File "/usr/lib64/python2.6/distutils/dist.py", line 975, in run_commands
    self.run_command(cmd)
  File "/usr/lib64/python2.6/distutils/dist.py", line 995, in run_command
    cmd_obj.run()
  File "/usr/lib/python2.6/site-packages/setuptools/command/easy_install.py", line 236, in run
    self.easy_install(spec, not self.no_deps)
  File "/usr/lib/python2.6/site-packages/setuptools/command/easy_install.py", line 472, in easy_install
    return self.install_item(spec, dist.location, tmpdir, deps)
  File "/usr/lib/python2.6/site-packages/setuptools/command/easy_install.py", line 502, in install_item
    dists = self.install_eggs(spec, download, tmpdir)
  File "/usr/lib/python2.6/site-packages/setuptools/command/easy_install.py", line 681, in install_eggs
    return self.build_and_install(setup_script, setup_base)
  File "/usr/lib/python2.6/site-packages/setuptools/command/easy_install.py", line 958, in build_and_install
    self.run_setup(setup_script, setup_base, args)
  File "/usr/lib/python2.6/site-packages/setuptools/command/easy_install.py", line 947, in run_setup
    run_setup(setup_script, args)
  File "/usr/lib/python2.6/site-packages/setuptools/sandbox.py", line 29, in run_setup
    lambda: execfile(
  File "/usr/lib/python2.6/site-packages/setuptools/sandbox.py", line 70, in run
    return func()
  File "/usr/lib/python2.6/site-packages/setuptools/sandbox.py", line 31, in <lambda>
    {'__file__':setup_script, '__name__':'__main__'}
  File "setup.py", line 1865
    exec(f.read(), globals(), fficonfig)
SyntaxError: unqualified exec is not allowed in function 'configure_ctypes' it contains a nested function with free variables
bash-4.1# SyntaxError: unqualified exec is not allowed in function 'configure_ctypes' it contains a nested function with free variables

当然,我不能从机器上删除Python 2.6.6,因为很多系统脚本依赖它。有什么想法怎么办?

python linux redhat
3个回答
0
投票

您需要找到Python-3.4软件包的源代码,或者自己构建它。

快速搜索找到http://wiki.guibin.info/?p=133自己构建Python-3.4。

通过更多搜索,您可以找到RPM软件包的源代码,但当然由您决定对这些软件包的信任程度 - 我不会在生产中使用随机RPM!


1
投票

我通常建议不要在RPM管理的发行版(如RHEL)上手动升级软件包。如果需要升级,则只能通过rpm升级来完成。 rpm工具存在的原因及其使用原因。实际上,有多个原因。它有一个重要的用途,手动安装或升级包完全颠覆了它。

如果绝对必要,以下程序应如下:

  1. 获取Red Hat的python包的源RPM。
  2. 抓住新版python的源代码。
  3. 弄清楚Red Hat的python RPM中的哪些补丁(如果有的话)仍适用于新版本的python。
  4. 使用python RPM中的spec文件来构建具有新版本python的rpms。
  5. 希望第4步有效。如果是的话,耶!安装它。如果没有,请找出原因,根据需要修补spec文件,返回步骤#4。
  6. 您现在安装了新版本的python。检查使用python的其他RHEL rpms是否都没有破坏新版本。如果没有,耶!你完成了。如果某些事情被打破,请弄清楚该怎么做。

许多RHEL系统管理工具和脚本都使用Python。由于安装了新的python包,因此最终被破坏的问题并非完全不可能。

使用RHEL的全部原因是拥有一个商业支持的稳定Linux发行版,其所有组件都已经过互操作性测试。升级它的随机部分错过了RHEL的全部要点;通常您升级到RHEL的整个新版本,而不是单个包;但是,他们自己......


1
投票

Red Hat提供了多个版本的Python(和其他软件包),可以作为软件集合的一部分并行安装。他们离开系统/ usr / bin /完整,并得到Red Hat的支持。

你需要:*启用RHSCL和可选软件repos *然后你可以yum install rh-python36python27(2.7.13)*使用scl enable rh-python 36 bash将python添加到你的路径。

How to install Python 3 on RHEL。它涵盖了使用多个版本的Python,Python虚拟环境和软件集合的许多技巧。

© www.soinside.com 2019 - 2024. All rights reserved.