Skip to content Skip to navigation

Using Python on CS Linux Machines

by Hanz Makmur

Python has lots of modules that come in many different versions and many different dependencies of specific version. Due to version conflicts, many of these modules conflict with other modules  and modules needed by the OS. To avoid these conflicts, we have created a unified python virtual environment for Computer Science CentOS 7.x Linux users to use. Below instruction assumes you are using bash shell.

To use  Python on CS machines, you simply need to follow 2 steps below:
 
1. Set a path to python environment
- To add a path type:export PATH="$PATH:/koko/system/anaconda/bin"  
Hint: To skip this step on your next login, add this line to your .bashrc 
 

 2. Activate the python environment of your choice.
- To activate python 3.6 environment (latest) type: source activate python36
- To activate python 3.5 environment  type: source activate python35
- To activate python 2.7 environment  type: source activate python27

Note: Python 2.7 is old, it is provided for compatibilities with older codes. Please update to Python 3.x

3. Other options
To see list of of available virtual environments, after activating an environment type: conda env list
- To exit or deactivate python virtual environment, type:  source deactivate

Once your specific python environment activated, you may need Integrated Development Environment (IDE) to simplify your tasks.  Here is a list of a few popular and free python IDEs

A. Available on CS Linux machines

  • idle : A basic IDE  for python27. To run idle in python27 environment type: idle
  • idle3: a basic IDE for python36To run idle in python35 or python36 environment type: idle3
  • spydera nice advanced IDE for python. To run spyder in your choice of python environment  type: spyder
  • jupyter Notebook (iPython): an interactive way to run python code on a browser. 
    To run jupyter on you need to open a terminal and depending on your session you would choose one of the following options. 
    If you are in:
    Graphical Session like X2Go, XRDP or Local login,  type: jupyter notebook --ip=`hostname` 
    this will start jupyter session and automatically open a browser on your graphical session.
    Non Graphical session like ssh type: jupyter notebook --ip=`hostname` --browser="none" 
    this start jupyter session but tells you to copy paste URL to your local browser.

    NOTE: The ` ` around hostname are backwards quotes. The backward quote key is normally at the upper left of your keyboard.

  • eclipse: a common and popular IDE. To run eclipse, type: eclipse or choose it from the Programming menu.

B. Not available on CS Linux machines

  • netbeans. A popular free Java IDE but python language support seems to be neglected on current release of Netbeans.
  • pycharm: A nice IDE free to install for your own computer.  We don't have licenses to install on our environment due to their license complex restrictions. 
  • Rodeo: A nice RStudio feel IDE but have issues that  have not been resolved since the founders have left. We dont have this on our system.
     
Installed Modules
 
For a list of modules already installed in specific environment, type:  conda list
 
Note: If python modules you use need GPU, please make sure to pick machines with GPU or it wont work. Here is a list of iLab machines and Graduate machines which list machines with GPU. 
 
If you are not using bash as your default shell,  before you can activate specific python environment above, you need to run bash and type the following:
bash
export PATH="$PATH:/koko/system/anaconda/bin"
 
 
Missing modules
 
We tried to put as many current working version of widely used modules as we can in these environments, If there are specific module you need that are not part of the virtual environment you are using, there are two options. You can install the module yourself immediately in your local path (see below) or request for the module to be installed so that everyone else benefit from it. If so, please send email to help@cs.rutgers.edu requesting the module to be installed. We will install these module if they are not conflicting with existing modules in a few days or so.
 
Installing modules for your own use
 
Python allows you to install module for your own use that is site specific. You can learn more about it by typing: pip install --help Example,  you can install a module using pip --install module_name --user

This command essentially install the module in your local path. To findout where the module is installed type python -m site --user-site

Please be aware that  your local modules may interfere with the modules already install in the evironment you are using if they are not maintained or updated over time.
 
Happy Coding!