title: How to deal with Linux/Python dependencies?
body: <p>Due to lack of support for some libraries I want to use, I moved some Python development from Windows to Linux development. I've spent most of the day messing about getting nowhere with dependencies.</p>
  
  <p><strong>The question</strong></p>
  
  <p>Whenever I pick up Linux, I usually run into some kind of dependency issue, usually with development libraries, whether they're installed via apt-get, easy_install or pip. I can waste days on what should be simple tasks, spending longer on getting libraries to work than writing code. <strong>Where can I learn about strategy for dealing with these kind of issues rather than aimlessly googling for someone who's come across the same problem before?</strong></p>
  
  <hr>
  
  <p><strong>An example</strong></p>
  
  <p>Just one example: I wanted to generate some QR codes. So, I thought I'd use <a href="https://github.com/bitly/pyqrencode" rel="nofollow noreferrer">github.com/bitly/pyqrencode</a> which is based on <a href="http://pyqrcode.sourceforge.net/" rel="nofollow noreferrer">pyqrcode.sourceforge.net</a> but supposedly without the Java dependencies. There are others (<a href="http://code.google.com/p/pyqrnative/" rel="nofollow noreferrer">pyqrnative</a>, <a href="https://github.com/Arachnid/pyqrencode/" rel="nofollow noreferrer">github.com/Arachnid/pyqrencode</a>) but that one seemed like the best bet for my needs.</p>
  
  <p>So, I found the package on <a href="http://pypi.python.org/pypi/pyqrencode" rel="nofollow noreferrer">pypi</a> and thought using that would make life easier:</p>
  
  <p>(I've perhaps made life more difficult for myself by using virtualenv to keep things neat and tidy.)</p>
  
  <pre><code>(myenv3)mat@ubuntu:~/myenv3$ bin/pip install pyqrencode
  Downloading/unpacking pyqrencode
    Downloading pyqrencode-0.2.tar.gz
    Running setup.py egg_info for package pyqrencode
  
  Installing collected packages: pyqrencode
    Running setup.py install for pyqrencode
      building 'qrencode' extension
      gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I/usr/include/python2.7 -c qrencode.c -o build/temp.linux-i686-2.7/qrencode.o
      gcc -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-Bsymbolic-functions build/temp.linux-i686-2.7/qrencode.o -lqrencode -o build/lib.linux-i686-2.7/qrencode.so
  
  Successfully installed pyqrencode
  Cleaning up...
  </code></pre>
  
  <p>(I guess I probably <code>sudo apt-get install libqrencode-dev</code> at some point prior to that too.)</p>
  
  <p>So then I tried to run the test script:</p>
  
  <pre><code>(myenv3)mat@ubuntu:~/myenv3$ python test_qr.py 
  Traceback (most recent call last):
    File "test_qr.py", line 1, in &lt;module&gt;
      from qrencode import Encoder
    File "qrencode.pyx", line 1, in init qrencode (qrencode.c:1520)
  ImportError: No module named ImageOps
  </code></pre>
  
  <p>:(</p>
  
  <p>Well, <a href="http://www.google.com/search?q=ImageOps" rel="nofollow noreferrer">investigations</a> revealed that ImageOps appears to be part of PIL...</p>
  
  <pre><code>(myenv3)mat@ubuntu:~/myenv3$ pip install pil
  Downloading/unpacking pil
    Downloading PIL-1.1.7.tar.gz (506Kb): 122Kb downloaded
  Operation cancelled by user
  Storing complete log in /home/mat/.pip/pip.log
  (myenv3)mat@ubuntu:~/myenv3$ bin/pip install pil
  Downloading/unpacking pil
    Downloading PIL-1.1.7.tar.gz (506Kb): 506Kb downloaded
    Running setup.py egg_info for package pil
      WARNING: '' not a valid package name; please use only.-separated package names in setup.py
  
  Installing collected packages: pil
    Running setup.py install for pil
      WARNING: '' not a valid package name; please use only.-separated package names in setup.py
      building '_imaging' extension
      gcc ...
      building '_imagingmath' extension
      gcc ...
      --------------------------------------------------------------------
      PIL 1.1.7 SETUP SUMMARY
      --------------------------------------------------------------------
      version       1.1.7
      platform      linux2 2.7.1+ (r271:86832, Apr 11 2011, 18:05:24)
                    [GCC 4.5.2]
      --------------------------------------------------------------------
      *** TKINTER support not available
      *** JPEG support not available
      *** ZLIB (PNG/ZIP) support not available
      *** FREETYPE2 support not available
      *** LITTLECMS support not available
      --------------------------------------------------------------------
      To add a missing option, make sure you have the required
      library, and set the corresponding ROOT variable in the
      setup.py script.
  
      To check the build, run the selftest.py script.
      ...
  Successfully installed pil
  Cleaning up...
  </code></pre>
  
  <p>Hmm, PIL's installed but hasn't picked up the libraries I installed with <code>sudo apt-get install libjpeg62 libjpeg62-dev libpng12-dev zlib1g  zlib1g-dev</code> earlier. I'm not sure how to tell pip to feed the library locations to setup.py. Googling suggests a variety of <a href="http://www.cleverkoala.com/2011/09/how-to-install-python-imaging-in-a-virtualenv-with-no-site-packages/" rel="nofollow noreferrer">ideas</a> which I've tried, but none of them seem to help much other than to send me round in circles.</p>
  
  <p><a href="https://stackoverflow.com/questions/6138848/ubuntu-11-04-installing-pil-into-a-virtualenv-with-pip">Ubuntu 11.04: Installing PIL into a virtualenv with PIP</a> suggests using the <a href="http://pypi.python.org/pypi/Pillow" rel="nofollow noreferrer">pillow</a> package instead, so let's try that:</p>
  
  <pre><code>(myenv3)mat@ubuntu:~/myenv3$ pip install pillow
  Downloading/unpacking pillow
    Downloading Pillow-1.7.5.zip (637Kb): 637Kb downloaded
    Running setup.py egg_info for package pillow
  
      ...
  Installing collected packages: pillow
    Running setup.py install for pillow
      building '_imaging' extension
      gcc ...
      --------------------------------------------------------------------
      SETUP SUMMARY (Pillow 1.7.5 / PIL 1.1.7)
      --------------------------------------------------------------------
      version       1.7.5
      platform      linux2 2.7.1+ (r271:86832, Apr 11 2011, 18:05:24)
                    [GCC 4.5.2]
      --------------------------------------------------------------------
      *** TKINTER support not available
      --- JPEG support available
      --- ZLIB (PNG/ZIP) support available
      --- FREETYPE2 support available
      *** LITTLECMS support not available
      --------------------------------------------------------------------
      To add a missing option, make sure you have the required
      library, and set the corresponding ROOT variable in the
      setup.py script.
  
      To check the build, run the selftest.py script.
      ...
  Successfully installed pillow
  Cleaning up...
  </code></pre>
  
  <p>Well, we seem to have the JPEG and PNG support this time, yay!</p>
  
  <pre><code>(myenv3)mat@ubuntu:~/myenv3$ python test_qr.py 
  Traceback (most recent call last):
    File "test_qr.py", line 1, in &lt;module&gt;
      from qrencode import Encoder
    File "qrencode.pyx", line 1, in init qrencode (qrencode.c:1520)
  ImportError: No module named ImageOps
  </code></pre>
  
  <p>Still no ImageOps though. Now I'm stumped, is ImageOps missing from pillow, or is it a different problem that was also there with pil.</p>