我有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,因为很多系统脚本依赖它。任何想法该怎么做?
答案 0 :(得分:1)
我通常建议不要在RPM管理的发行版(如RHEL)上手动升级软件包。如果需要升级,则只能通过rpm升级来完成。 rpm工具存在的原因及其使用原因。实际上,有多个原因。它有一个重要的用途,手动安装或升级包完全颠覆了它。
如果绝对必要,以下程序应如下:
许多RHEL系统管理工具和脚本都使用Python。由于安装了新的python软件包,最终导致某些内容被破坏并不是完全不可能的。
使用RHEL的全部原因是拥有一个商业支持的稳定Linux发行版,其所有组件都已经过互操作性测试。升级它的随机部分错过了RHEL的全部要点;通常您升级到RHEL的整个新版本,而不是单个包;但是,他们自己......
答案 1 :(得分:1)
Red Hat提供了多个版本的Python(和其他软件包),这些版本可以作为软件集合的一部分并行安装。它们使系统/ usr / bin /完好无损,并受到Red Hat的支持。
您需要:
*启用RHSCL和可选软件仓库
*然后您可以yum install rh-python36
或python27
(2.7.13)
*使用scl enable rh-python 36 bash
将python添加到您的路径。
请参见How to install Python 3 on RHEL。它涵盖了使用多个版本的Python,Python虚拟环境和软件集合的许多技巧。
答案 2 :(得分:0)
您需要找到Python-3.4软件包的源代码,或者自己构建它。
快速搜索找到http://wiki.guibin.info/?p=133来自行构建Python-3.4。
通过更多的搜索,您可以找到RPM软件包的来源,但当然由您自己对这些软件包的信任程度 - 我不会使用随机RPM生产!