Skip to content

Python

Using Python w/ Local Packages

There is a global installation of the Anaconda Python distribution which is enabled by default for each user. Only users with administrative privileges can install additional packages.

To install your own packages, you need to create a local environment in your home directory.

For now, let's be cheeky and call this environment ddg.

(base) volkerh@ds01:~$ conda create --name ddg python=3.6

This creates a Python 3.6 environment called ddg. We suggest to stay on Python 3.6 until all the growing pains of Python 3.7 are sorted.

Every time you log in, you need to select this environment, i.e.

(base) volkerh@ds01:~$ conda activate ddg

Note that your prompt should change to something like

(ddg) volkerh@ds01:~$ 

You can now install whatever packages you want. If possible, try to use Anaconda rather than pip.

For example, to install your local version of the Python data science stack, do

(ddg) volkerh@ds01:~$ conda install ipython pandas numpy scipy scikit-learn matplotlib

If you want to install stuff through pip, you need to pass --trusted-host files.pythonhosted.org to sidestep the MITM proxy, viz.

(ddg) volkerh@ds01:~$ pip install tqdm --trusted-host files.pythonhosted.org

Install/Run Python EDG

To run your own version of the Python EDG, you need to obtain the code from somewhere. Assuming you've extracted it to /home/username/src/python-edg, you can now simply install it via

(ddg) volkerh@ds01:~$ cd /home/username/src/python-edg/
(ddg) volkerh@ds01:~$ python ./setup.py install

If this fails, note that PEDG has a dependency on lxml, which you can install via

(ddg) volkerh@ds01:~$ conda install lxml

Now, retry the above.

To verify the installation, try to import the module in IPython, i.e.

(ddg) volkerh@ds01:~$ cd ~
(ddg) volkerh@ds01:~$ ipython
Python 3.6.8 |Anaconda, Inc.| (default, Dec 30 2018, 01:22:34) 
Type 'copyright', 'credits' or 'license' for more information
IPython 7.3.0 -- An enhanced Interactive Python. Type '?' for help.

In [1]: import pedg

In [2]: 

This should go without a hitch.

Install/Run DDG (Dynamic Dataset Generator)

Again, we assume you have obtained the DDG from some unspecified source and have extracted it to /home/username/src/ddg.

First, we need to install all dependencies, cf.

(ddg) volkerh@ds01:~$ conda install matplotlib pandas pillow pathlib requests lxml

Now, just navigate to the following directory and launch the DDG.

(ddg) volkerh@ds01:~$ cd /home/username/src/ddg
(ddg) volkerh@ds01:/home/username/src/ddg$ cd DDG
(ddg) volkerh@ds01:/home/username/src/ddg/DDG$ python ./run_program.py

That's it!

NB: If you get an error like this, you need to enable X forwarding.

Traceback (most recent call last):
  File "./run_program.py", line 17, in <module>
    root = Tk()
  File "/home/vtest/.conda/envs/ddg/lib/python3.6/tkinter/__init__.py", line 2023, in __init__
    self.tk = _tkinter.create(screenName, baseName, className, interactive, wantobjects, useTk, sync, use)
_tkinter.TclError: no display name and no $DISPLAY environment variable

If you connect from Linux, it's a simple as ssh -X user@ds01. If you connect from macOS, it's the same except you need to install XQuartz as well. If you connect from Windows, you need to enable X forwarding in your SSH client (Putty?) as well as install XMing.