Linux: Using Canopy on "headless" servers

Enthought Canopy is both a new graphical data analysis environment, and an update to the Enthought Python Distribution (EPD). While use of the Canopy graphical environment does require a display, Canopy can be installed and run on "headless" machines where only a command line is available. Two options exist.

Using Canopy via a remote X11 display

For users who want to use the graphical environment and have an X11 (X Window System) server available, Canopy can be set to display to a remote server. To do this, set the 'DISPLAY' environment variable, on the Canopy machine, to point to the machine the X11 server is running on. A typical setting looks like this (in Bash syntax):

    export DISPLAY=192.168.1.2:0

where 192.168.1.2 is the IP address of the machine running the X11 server and ":0" refers to the screen number (zero in most cases).

Using Canopy purely from the command line as a Python environment

Canopy is based on the use of virtual environments. Virtual environments let users create what are effectively multiple, light-weight Python installations. The full Python environment, and a set of core packages, are available in the base environment (in this case the Canopy install itself). Users can then install packages into one or more separate virtual environments without having to duplicate the core.

In a typical Canopy GUI setup, two virtual environments ("System" for the Canopy GUI itself, and "User" for running your own programs) are created when Canopy is first started. You can read more about this configuration here.

In contrast, to use Canopy in a headless environment, you only need to set up a single virtual environment. In Canopy 1.1 (mid-August release) this setup will be streamlined. At present, it requires the following manual steps on Linux:

1. Install Canopy from the downloaded .sh script. This can be in your home directory, in a protected shared directory, or any other directory. Later, you will not need to have write access to this directory to install packages.

2. Run the following command (assumes you installed Canopy in the default ~/Canopy directory, adjust as needed):

~/Canopy/appdata/canopy-1.0.0.1160.rh5-x86_64/bin/python ~/Canopy/appdata/canopy-1.0.0.1160.rh5-x86_64/bin/venv -s ./canopy_1

This command creates a new virtual environment in ./canopy_1 (or wherever you specify).

3. Add ./canopy_1/bin to your PATH environment variable or, if you are using bash, you can type:

. ./canopy_1/bin/activate

If you type `'which python'` you should now be using the Python from the virtual environment and you can use this, just as you would use EPD. To install new packages, just use the "enpkg" command as you would do in EPD.

While setting up a virtual environment requires an additional step, the advantage is that you can easily create multiple virtual environments to keep applications separate, or to experiment with new package versions without disrupting a known good environment. Again, this process will be streamlined in Canopy 1.1.

Have more questions? Submit a request

Comments

  • Avatar
    Bovy Benoit

    I had some trouble with canopy-1.0.3.1262.rh5-x86_64 when following the procedure above for the 1st time.

    I have installed Canopy (from the sh script) in /opt/Canopy (as root)

     

    When I created a new virtual environment for the 1st time, with the following command (as user):

    /opt/Canopy/appdata/canopy-1.0.3.1262.rh5-x86_64/bin/python /opt/Canopy/appdata/canopy-1.0.3.1262.rh5-x86_64/bin/venv -s  path/to/myenv

    I got this error:

    Unable to load library icui18n "Cannot load library icui18n: (icui18n: cannot open shared object file: No such file or directory)"

    : cannot connect to X server

     

    Connecting with X11 support ("ssh -X") solved the problem. The command above opened a window with the path setup for Canopy (as for the default installation procedure), and then created the new virtual environment.

    I successfully activated the virtual environment, but the following command failed :

    enpkg --help

    -bash: path/to/myenv/bin/enpkg: myenv/bin/python: bad interpreter: No such file or directory

     

    After that, I created other virtual environments without any problem (no X11 window, "enpkg" command works...)

  • Avatar
    Alexander Mikheyev

    I am having the same problem. Unfortunately, while the making another environment doesn't require X11, I still get the same "bad interpreter" error with enpkg

  • Avatar
    Miha Pelko

    For me it also seems X11 are still required to run:

    /opt/Canopy/appdata/canopy-1.0.3.1262.rh5-x86_64/bin/python /opt/Canopy/appdata/canopy-1.0.3.1262.rh5-x86_64/bin/venv -s  path/to/myenv

  • Avatar
    Pawel Kublas

    I still cannot setup single virtual environment; running this command via SSH and PuTTy:

    user@ip-1-1-1-1:~$ ~/Canopy/appdata/canopy-1.0.3.1262.rh5-x86_64/bin/python ~/Canopy/appdata/canopy-1.0.3.1262.rh5-x86_64/bin/venv -s ./canopy_1

    Unable to load library icui18n "Cannot load library icui18n: (icui18n: cannot open shared object file: No such file or directory)"

    : cannot connect to X server

  • Avatar
    Kambiz Tavabi

    First option doesn't work for me with either an explicit IP address or DISPLAY = localhost:0. Results in message: Unable to load library icui18n "Cannot load library icui18n: (icui18n: cannot open shared object file: No such file or directory)" : cannot connect to X server

  • Avatar
    Jeff Alstott

    Still the case that this isn't working in 1.1:

    $ Enthought/Canopy_64bit/User/bin/canopy_cli update

    Unable to load library icui18n "Cannot load library icui18n: (icui18n: cannot open shared object file: No such file or directory)"

    -c: cannot connect to X server

     

    Only works if I use ssh -X to get into the server where I'm running this. Command line interfaces should not require connection to X.

  • Avatar
    Bovy Benoit

    Maybe this post is now useless for Canopy 1.1, which introduce a new command line interface.

    http://docs.enthought.com/canopy/configure/canopy-cli.html

    I haven't tried it yet...

  • Avatar
    Bovy Benoit

    Oups, sorry !

    I didn't read the comment carefully.

  • Avatar
    Thiago Marzagao

    I'm using the new command line interface ( http://docs.enthought.com/canopy/configure/canopy-cli.html) and getting the same error.

    I try this:

    ~/Canopy/canopy_cli --no-gui-setup --install-dir /usr/local

    And get this:

    Unable to load library icui18n "Cannot load library icui18n: (icui18n: cannot open shared object file: No such file or directory)" 

    __boot__.py: cannot connect to X server 

  • Avatar
    John Bushnell

    I just confirmed that this is still an issue, using canopy-1.3.0-full-rh5-64.sh installer on CentOS 6.

    [root@myserver ~]# Canopy/canopy_cli --no-gui-setup update

    __boot__.py: cannot connect to X server

    Strange behavior for a tool with "cli" in the name.