简体   繁体   中英

Install python2.7 in Linux though Chef recipe

I am trying to upgrade the Python version in my Linux Box.

[root@box1 ~]# python --version
Python 2.6.6 
[root@box1 ~]# 

I running:

yum install python27

and after this to reflect python 2.7 version, I am running :

scl enable python27 bash

for the current session it's giving

[root@box1 ~]# python --version 
Python 2.7.8
[root@box1 ~]# 

When I am trying to write Chef cookbook, my recipe looks like this:

# install python27 package
yum_package 'python27' do
 action :install
end

# enable python27 bash
execute 'python27_bash' do
  command 'scl enable python27 bash'
end

and I am calling this cookbook in the node, but its not upgrading to the python2.7 for the current session.

So when you run scl enable python27 bash it is actually spawning a new Bash process from your current shell. Because of how SCLs work, you can only enable them for a new process. Use the poise-python cookbook to work around this, its python_runtime resource has an SCL provider which handles the internal magic for you.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM