Search code examples
python-3.xchef-infratest-kitchen

How to install python 3.5 in chef


I am trying to install python 3.5 in a chef recipe. I tried using the poise-python cookbook. After reading the documentation. I tried the following command, but it doesn't install python 3.5. It installs python2.7

python_runtime 'python3' do
version '3.5'
end

The output

 * python_runtime[python3] action install
   * poise_languages_scl[rh-python35] action install
     * yum_package[centos-release-scl-rh] action upgrade
- upgrade package centos-release-scl-rh from uninstalled to 2-2.el7.centos
     * ruby_block[flush_yum_cache] action run
- execute the ruby block flush_yum_cache
     * yum_package[rh-python35] action install
- install version 2.0-2.el7 of package rh-python35
     * yum_package[rh-python35-python-devel] action install (up to date)

   * python_runtime_pip[python3] action install (up to date)
   * python_package[setuptools] action install (up to date)
   * python_package[wheel] action install
     - install version 0.29.0 of package wheel

Any help would be appreciated. I can go the route of using execute to run the install commands but would prefer to use a cookbook.


Solution

  • As you can see in the log, it is installing 3.5 via the SCL packages. I'm guessing you are thinking it is 2.7 because you're running /usr/bin/python -v manually afterwards. That is not how you use SCL packages, run scl enable rh-python35 "python -v" and you'll see 3.5. The cookbook does this for you internally.