Reputation: 570
I have Python 2.6.6. to run a certain script on my Red Hat Linux VM. Need to upgrade to 3.4.1. Tried
easy_install --upgrade python
But I always get
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
And of course I can't delete Python 2.6.6 from the machine as a lot of system scripts depend on it. Any ideas what to do?
Upvotes: 0
Views: 2760
Reputation: 386
Red Hat supplies multiple versions of Python (and other packages) that can be installed in parallel as part of software collections. They leave the system /usr/bin/ intact and are supported by Red Hat.
You need to:
* enable the RHSCL and optional software repos
* then you can yum install rh-python36
or python27
(2.7.13)
* Use scl enable rh-python 36 bash
to add python to your path.
See How to install Python 3 on RHEL. It covers many tips for working with multiple versions of Python, Python virtual environments, and software collections.
Upvotes: 1
Reputation: 118350
I generally advise against manually upgrading packages on an RPM-managed distribution such as RHEL. If an upgrade is needed, it should only be done by upgrading via rpm. There is a reason why the rpm tools exists, and why it is used. There's more than one reason, actually. It serves an important purpose, and manually installing or upgrading packages completely subverts it.
If it's absolutely necessary, the following procedure should be as follows:
Many RHEL system management tools and scripts use Python. It's not entirely out of the question that something ends up being broken, as a result of the new python package being installed.
The whole reason for using RHEL is to have a commercially-supported, stable Linux distribution whose all components have been tested for interoperability. Upgrading random parts of it misses the whole point of having RHEL; typically you upgrade to an entire new release of RHEL, instead of the individual packages; but, to each their own...
Upvotes: 1
Reputation: 419
You will need to find a source for Python-3.4 packages, or build it yourself.
A quick search finds http://wiki.guibin.info/?p=133 for building Python-3.4 yourself.
With some more searching, you may be able to find a source for RPM packages, but of course it's up to you how much you trust those packages -- I wouldn't use a random RPM in production!
Upvotes: 0