This shows you the differences between two versions of the page.
| Both sides previous revision Previous revision Next revision | Previous revision | ||
|
howto:python:start [2019/08/22 14:58] agill [User Package installation with Anaconda] |
howto:python:start [2021/12/09 16:42] (current) |
||
|---|---|---|---|
| Line 1: | Line 1: | ||
| ====== Python ====== | ====== Python ====== | ||
| - | .profile | + | See the [[guide:python|Python |
| - | source .bashrc | + | |
| - | + | ||
| - | .bashrc : | + | |
| - | + | ||
| - | export PATH=$HOME/ | + | |
| - | + | ||
| - | #gcc 4.7.2 | + | |
| - | module add gcc/4.7.2 | + | |
| - | export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/ | + | |
| - | + | ||
| - | # Python 2.6.5 on / | + | |
| - | export PATH=/ | + | |
| - | export LD_LIBRARY_PATH=/ | + | |
| - | + | ||
| - | Thats it. The / | + | |
| - | $ ipython | + | |
| - | $ import numpy | + | |
| - | $ numpy.test() | + | |
| - | + | ||
| - | ===== Installing packages ===== | + | |
| - | + | ||
| - | Assuming your codes are to be run on the dell cluster, add the following lines to your .bashrc file | + | |
| - | #if feature=dell check still needs to be added | + | |
| - | export PYTHONPATH=~/ | + | |
| - | export PATH=$HOME/ | + | |
| - | + | ||
| - | create the required directories | + | |
| - | $ mkdir -p $HOME/ | + | |
| - | $ mkdir -p $HOME/ | + | |
| - | + | ||
| - | + | ||
| - | ==== setuptools ==== | + | |
| - | + | ||
| - | Use for tool for managing and install Python packages. Setuptool provides the // | + | |
| - | + | ||
| - | $ cd tmp | + | |
| - | $ wget http:// | + | |
| - | $ tar -xf setuptools-0.6c11.tar.gz | + | |
| - | $ cd setuptools-0.6c11 | + | |
| - | $ python setup.py install --prefix=$HOME/ | + | |
| - | + | ||
| - | ==== argparse ==== | + | |
| - | + | ||
| - | From the login node (which has http access) simply | + | |
| - | $ easy_install --prefix=$HOME/ | + | |
| - | + | ||
| - | + | ||
| - | ==== numpy (minimal) ==== | + | |
| - | + | ||
| - | $ msub -I -l feature=dell | + | |
| - | $ cd ~/tmp | + | |
| - | $ ssh login01 wget http:// | + | |
| - | $ mv ../ | + | |
| - | $ tar -xf numpy-1.6.2.tar.gz | + | |
| - | $ cd numpy-1.6.2 | + | |
| - | $ export ATLAS=None | + | |
| - | $ export BLAS=None | + | |
| - | $ export LAPACK=None | + | |
| - | $ python setup.py build --fcompiler=gnu95 | + | |
| - | $ python setup.py install --prefix=$HOME/ | + | |
| - | + | ||
| - | when testing you should get | + | |
| - | $ ipython | + | |
| - | import numpy | + | |
| - | numpy.test() | + | |
| - | Ran 3568 tests in 11.266s | + | |
| - | + | ||
| - | OK (KNOWNFAIL=5, | + | |
| - | Out[3]: < | + | |
| - | + | ||
| - | ==== scipy (minimal) ==== | + | |
| - | + | ||
| - | + | ||
| - | $ msub -I -l feature=dell | + | |
| - | $ cd ~/tmp | + | |
| - | $ ssh login01 wget http:// | + | |
| - | $ mv ../ | + | |
| - | $ tar -xf scipy-0.10.1.tar.gz | + | |
| - | $ cd scipy-0.10.1/ | + | |
| - | $ python setup.py build --fcompiler=gnu95 #takes about 10 minutes to build | + | |
| - | $ python setup.py install --prefix=$HOME/ | + | |
| - | + | ||
| - | testing, | + | |
| - | $ cd ~/ | + | |
| - | $ ipython | + | |
| - | import scipy | + | |
| - | scipy.__path__ | + | |
| - | scipy.test() | + | |
| - | + | ||
| - | which did not work 100 % :( | + | |
| - | + | ||
| - | FAILED (KNOWNFAIL=13, | + | |
| - | Out[2]: < | + | |
| - | + | ||
| - | ==== matplotlib / pylab ==== | + | |
| - | + | ||
| - | $ msub -I -l feature=dell | + | |
| - | $ cd ~/tmp | + | |
| - | $ ssh login01 wget http:// | + | |
| - | $ mv ../ | + | |
| - | $ tar -xf matplotlib-1.2.0.tar.gz | + | |
| - | $ cd matplotlib-1.2.0 | + | |
| - | $ python | + | |
| - | + | ||
| - | ==== mpi4py ==== | + | |
| - | + | ||
| - | Is already installed, all that is needed is to load the openmpi module; add the following line to // | + | |
| - | module add openmpi-1.6.1-intel | + | |
| - | + | ||
| - | ==== User Package installation with Anaconda === | + | |
| - | Modules for anaconda version 2 and 3 are installed on lengau.To load these modules, use the following command (either from the command-line in an interactive session, or in a script: | + | |
| - | module add chpc/ | + | |
| - | or: | + | |
| - | module add chpc/ | + | |
| - | + | ||
| - | Using virtualenv with anaconda is not recommended. | + | |
| - | However, Anaconda does include a similar functionality, | + | |
| - | + | ||
| - | The following instructions to set up your virtual environment. **YOU NEED ONLY DO THEM ONCE. Please replace USERNAME with your actual username wherever it occurs below.** | + | |
| - | + | ||
| - | 1. log into lengau | + | |
| - | + | ||
| - | 2. '' | + | |
| - | + | ||
| - | 3. '' | + | |
| - | + | ||
| - | 4. '' | + | |
| - | + | ||
| - | 5. '' | + | |
| - | + | ||
| - | 6. '' | + | |
| - | _You don't have to use " | + | |
| - | + | ||
| - | 7. You can now install whatever packages you need, that are not installed already for instance, for rpy2, type: | + | |
| - | + | ||
| - | conda install rpy2 | + | |
| - | + | ||
| - | 8. you can now type: | + | |
| - | conda deactivate / | + | |
| - | to exit the virtual environment. | + | |
| - | + | ||
| - | + | ||
| - | Now, once you've done this, you MUST DO THE FOLLOWING IN YOUR JOB-SUBMIT SCRIPT: | + | |
| - | Put it all near the top of your script, but after the #PBS directives: | + | |
| - | + | ||
| - | module add chpc/ | + | |
| - | + | ||
| - | conda activate / | + | |
| - | + | ||
| - | and at the end: | + | |
| - | conda deactivate / | + | |
| - | + | ||
| - | Then submit your script as normal with qsub. | + | |
| - | + | ||
| - | + | ||
| - | if you ever need to install new python packages, just repeat steps 1, 2, 3, 6, 7 and 8 from above. (omit 4 and 5). | + | |
| - | + | ||
| - | + | ||
| - | + | ||