How to install Anaconda and use Python packages

This article provides the guidance for using Python with Anaconda in the Developer Cloud Sandbox.

There are a few steps to follow:

  1. Install Anaconda 
    
  2. Search, install and remove Anaconda Python packages
    
  3. Use the Anaconda Python distribution
    

Installing Anaconda

Run the simple step below on the Developer Cloud Sandbox shell:

sudo yum install -y miniconda

Using Anaconda

  • To search for a package:
    

sudo conda search <search term>

  • To install a package:
    

sudo conda install <package>

  • To remove a package:
    

sudo conda remove <package>

Using Python

Before invoking the Python executable from the shell, add the Anaconda path to the PATH environment variable:

export PATH=/opt/anaconda/bin:$PATH
python -V
Python 2.7.11 :: Continuum Analytics, Inc.

1 Like

How do you include information like this when packaging the application? I’m guessing it should be stated somewhere in the pom or in a requirements file or such? We also need to use packages from other channels than the default anaconda one, so it needs to support that.

I seen different partial solutions:

The last solution seems like the one that is most “in synch” with the idea of using the pom to control it all. But it is partially incomplete due to missing the package file itself, and also documentation.

Do you have some best-practices, recommendations, or good examples on this matter?

Hi Alexander,

actually, the first solution is the good one.
The command to list the installed conda packages, and put them in a file, is managed by a parent POM (i.e., dcs-python-parent). Then, it also includes a postinstall scriptlet section, to install them during the post install phase of the Application’s RPM.

It’s automatically done, leveraging the parent POM mentioned above.

We support a list of channels, and you can get the list with sudo conda info.
We recently added the support for conda-forge, with the lowest priority (because it’s not stable enough).

If you want to see the full processed POM, you can use the following command:

mvn help:effective-pom

Hope this helps,

Best regards
Cesare Rossi
the Operations Support team at Terradue