问题
Is there a way to permanently enable custom Software Collections for RedHat?
I have installed an scl to provide python27 in RHEL6 and don't want to have to enable the custom scl every time.
回答1:
Well, you could add something to your startup script to source the enable script.
Eg add to your .bash_profile
(note space between initial dot
and /
)
. /opt/rh/python27/enable
回答2:
This option sounds dangerous to me for root. I would think something like the following would be safer and more appropriate:
You can create a function that takes command line options. Think of this as an alias on steroids. Add the following to your .bashrc
python27() {
scl enable python27 “python $*”
}
Then test:
python27 –version
Python 2.7.5
This doesn’t help with your magic line in scripts, but will make it easier to call scripts:
[smccarty@keith ~]$ cat script.py
#!/usr/bin/env python27
import sys
print “Hello, World!”, sys.version
Call it normal and notice, the default installation of python is used:
[smccarty@keith ~]$ ./script.py
Hello, World! 2.6.6 (r266:84292, Sep 4 2013, 07:46:00)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-3)]
Call it with our alias, and notice that Python 2.7 is used:
[smccarty@keith ~]$ python27 script.py
Hello, World! 2.7.5 (default, May 23 2013, 06:08:09)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-3)]
来源:https://stackoverflow.com/questions/21264601/permanently-enable-rhel-scl