Permanently enable RHEL scl

牧云@^-^@ 提交于 2019-12-03 11:15:03

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!