You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 21 Next »

Sometimes it is useful to install python packages that are not part of psana-python or install particular versions of a software package.  These should be done from the "psbuild-rhel7" machines since they have internet access.  In particular "psana" nodes do NOT have internet access.

Anaconda

If you want to get a conda environment with psana you can clone the psana environment into a local environment that you can control with a command like this (which will take some time because it has to copy several GB to the new environment):

conda create -n my-ana-1.3.10 --clone ana-1.3.10

You can also create new (empty) environments without cloning.  You can see a list of available psana environments (to clone) like this:

conda info --envs

Then activate your new environment with:

source activate my-ana-1.3.10

Then install the conda-python package you want (potentially a specific version) using a command like:

conda install scipy=0.15.0

Note that package version conflicts can make it impossible to install a specific version.  One possible way to address this is to remove the package requiring the conflicting version using:

conda remove <packagename>

Anaconda+pip

Some packages are not available from anaconda but they can be installed via pip (in this case the "rayopt" package):

source activate ana-1.3.44
pip install --user rayopt

If you change psana versions at a later time, the package you installed previously with pip may not work anymore.  If so you can uninstall the old version with "pip uninstall rayopt" and install it again using the new version of psana.

Making Your Own Conda Environment Visible In Jupyter

If you build your own conda environment - or want to use one of your colleagues one -  which contains a python jupyter kernel (package ipykernel) you can make it visible to the jupyter hub by creating a kernelspec files. For a user the spec files are located in ~/.local/share/jupyter/kernels/ with a sub-directory for each spec. The kernel.json in a spec directory contains the settings. For an example see  ~wilko/.local/share/jupyter/kernels/example/.

An easy way to create the proper folder and spec files is to use the ipython command:

% conda activate <your-env>
% ipython kernel install --user --name "a-name-you-like"

The --name option is the name for the kernelspec - the directory that will be created in ~/.local/share/jupyter/kernels/. There are a few more install options - ipython kernel install -h - the most useful one is --display-name  that allows to set the name shown in Jupyter. Instead of using the command above one can also create the directory and the kernel.json file by hand. You

Virtualenv

NOTE: the virtualenv method is not compatible with our anaconda-based psana, but we leave the documentation here in case it is useful at some point.

A python virtualenv can be used to install python packages locally in your user account.  Some instructions are here.  Execute this command to create a new virtual environment (after setting up the psana psana environment):

virtualenv <directoryName>

where you replace <directoryName> with the name of the directory you would like to create.  Then activate your virtualenv like this:

source <directoryName>/bin/activate.csh     #use this for tcsh
 
or
 
source <directoryName>/bin/activate         #use this for bash

Use "deactivate" to exit the virtualenv.  Install various packages using "pip install <packageName>" as shown in these instructions.  Virtualenv packages can be used in batch jobs, but you must submit the job while the environment is active.

  • No labels