Installation pylabrad Kubuntu 14.04 - syue99/Lab_control GitHub Wiki
Install and Make Virtual Environment
In general, virtualenv and virtualenvwrapper python packages provide a good way to maintain and version-control all the python libraries. The basic idea is that one creates a virtual environment where libraries are installed and maintained. In the virtual environment, libraries don't auto-update and are isolated from the system libraries. This is particularly important in Kubuntu given the system's use of PyQt.This reference provides a good guide to using virtual environments with the virtualenvwrapper class, simplifying the usage.
Kubuntu 14.04 comes with Python 2.7.6 we will use it to create virtual environment. First, install pip:
sudo apt-get install python-pip python-dev build-essential -y
Then update pip and install virtual environment:
sudo pip install --upgrade pip
sudo pip install virtualenv virtualenvwrapper
Start using the virtual environment. To make permanent add this command to /etc/bash.bashrc or ~/.bashrc
source virtualenvwrapper.sh
Then make a new virtual env
mkvirtualenv labrad
Install pylabrad
There are two ways to install pylabrad described in the subsections below.
Through PIP
This is the easiest way but may not provide the latest bug-fixes.
workon labrad
pip install twisted
pip install pylabrad
In case of errors, may need to run the pip install commands with sudo.
SVN Checkout
Gets the latest source code
workon labrad
pip install twisted
cd ~/Downloads
sudo apt-get install subversion -y
svn co https://svn.code.sf.net/p/pylabrad/svn/trunk pylabrad
cd pylabrad
python setup.py install
Additional Packages
In addition to the basic pylabrad installation, the user may want to install scientific processing or graphical python libraries, or drivers. Keep in mind these have to be installed in the virtual environment.
numpy
pip install numpy
matplotlib
sudo apt-get build-dep python-matplotlib -y
pip install matplotlib
configure to use Qt4 backend
Edit configuration file found with
workon labrad
python
import matplotlib
print matplotlib.matplotlib_fname()
to state:
backend : Qt4Agg
scipy
sudo apt-get install libatlas-base-dev gfortran -y
pip install scipy
pyserial
pip install pyserial
miscellaneous pip packages
pip install bitarray ipython psutil treedict
qutip
pip install cython && pip install qutip
PyQt
PyQt is needed for development and execution of graphical applications. To install, one needs to first build SIP. We will download SIP 4.15.5 (latest version at the time of writing this) from http://www.riverbankcomputing.com/software/sip/download.
To install SIP:
sudo apt-get install g++ byacc flex -y
cd ~/Downloads/
wget http://sourceforge.net/projects/pyqt/files/sip/sip-4.15.5/sip-4.15.5.tar.gz
tar -xvzf sip-4.15.5.tar.gz
workon labrad
cd sip-4.15.5/
python configure.py
make
sudo make install
We will download the latest PyQt version (4.10.4 at the time of writing this) from http://www.riverbankcomputing.co.uk/software/pyqt/download
To install PyQt:
sudo apt-get install qt4-dev-tools libxext-dev libxext6 qt4-designer -y
cd ~/Downloads/
wget http://sourceforge.net/projects/pyqt/files/PyQt4/PyQt-4.10.4/PyQt-x11-gpl-4.10.4.tar.gz
tar -xvzf PyQt-x11-gpl-4.10.4.tar.gz
cd PyQt-x11-gpl-4.10.4
workon labrad
python configure.py
make
make install
- If you see an error about sipconfig, make sure that sipconfig.py in site-packages has the right ownership.
Opal Kelly API
First, copy and extract the FrontPanelUSB-FC15-64-4.0.3.tgz from the CD that came with the FPGA (use the 32 bit version if appropriate):
tar -xvzf FrontPanelUSB-FC15-64-4.0.3.tgz
Now we will follow a Ubuntu-adapted version of install.sh:
cp ./60-opalkelly.rules /etc/udev/rules.d
cp API/libokFrontPanel.so /usr/local/lib/
cp -r API/okFrontPanelDLL.* /usr/local/include/
Then reboot and copy the files in API/Python/ to the ok subfolder of the site-packages folder of the virtual environment.
Desktop Shortcuts
It is convenient to make a desktop launch for example, to launch the the node server. To do that, first make a bash script startNodeServer.sh as follows:
#!/bin/bash
source virtualenvwrapper.sh
workon 'labrad'
twistd -n labradnode
exit 0
and then make a desktop launcher with the command. The -i option is necessary for the script to be aware of the standard environmental variables.
bash -i /some_path/startNodeServer.sh