Hoffman2:Python: Difference between revisions
Line 67: | Line 67: | ||
conda deactivate | conda deactivate | ||
=== CCN existing Conda Environments === | |||
ccn_py37 | |||
/u/project/CCN/apps/conda/rh7/ccn_py37 | |||
tf230 | |||
/u/project/CCN/apps/conda/rh7/bcgnet/tf230 | |||
==Python 2 Statement== | ==Python 2 Statement== |
Revision as of 23:54, 9 February 2022
Use Python in Hoffman2
Use Python modules
module av python
This will show all the available Python modules in Hoffman2
python/2.7.15 python/2.7.18 python/3.6.8(default) python/3.7.3 python/3.9.6
Be aware that the default version is python/3.6.8. To use a specific version, use command for example
module load python/3.7.3
Install Python libraires
Here shows the way to install Python libraries into your user space, which is under ~/.local
pip3 install library_name --user
For example
pip3 install scipy --user
This will install Scipy library into your ~/.local. Add the following to your ~/.bashrc
export PATH=$HOME/.local/bin:$PATH
Use Conda for Python virtual environment
Conda is very handy for managing Python environment. One can create multiple Conda environment for different purpose.
For example, if one application you want to use requires Python 3.6 but another application requires Python 3.7, you can have two separate Conda environments with one providing Python 3.6 and the other with Python 3.7.
To use conda, first load the module
module load conda
Then run the following command to setup the path
source $CONDA_DIR/etc/profile.d/conda.sh
Next, generate a conda environment with your preferred Python version
conda create --prefix /u/project/YOUR_GROUP/YOUR_CONDA_ENV_NAME python=3.7.3
This will generate a conda environment with python 3.7.3 (you can choose other existing version)
Activate your Conda environment
conda activate /u/project/YOUR_GROUP/YOUR_CONDA_ENV_NAME
Then you should see the ssh prompt changes to (/u/project/YOUR_GROUP/YOUR_CONDA_ENV_NAME) in front of your cursor. This means you are inside of the Conda virtual environment
Try check the Python version and see if it matches what you have picked
python --version
Then you can install other Python libraries you need here by "pip install". For example,
pip install numpy
This will install Numpy into this environment.
One you want to leave this Conda environement, just type in
conda deactivate
CCN existing Conda Environments
ccn_py37
/u/project/CCN/apps/conda/rh7/ccn_py37
tf230
/u/project/CCN/apps/conda/rh7/bcgnet/tf230
Python 2 Statement
Python 2 has officially reached its End of Life (EOL). That means that it will no longer be receiving active support or updates from their core development team as of January 1st, 2020.
As a result, several open-source packages have pledged to drop support for Python 2.7. For more information about these participating projects, please refer to the Python 3 Statement https://python3statement.org/