How to install SIP+PyQt with apt-get + pip + virtualenv?

15,897

The main problem here is that virtualenv seems to prefer to symlink /usr/include instead of copying those files to $VIRTUAL_ENV/include (you can check this while inspecting the source code of virtualenv: /usr/local/lib/python2.7/dist-packages/virtualenv.py in my system).

An easy solution would be just remove the symlink and copy those files from /usr/include:

$ cd $VIRTUAL_ENV/include/
$ rm python2.7
$ cp -r /usr/include/python2.7/ .

Please note that you may have symlinks on /usr/include/python2.7 pointing to relative locations, so when you copy those files they will become broken.

Then you only need a little modification:

$ python configure.py --incdir="$VIRTUAL_ENV/include/python2.7"
$ make
$ make install

BTW: if you want to force virtualenv to copy those files instead of symlink'ing, just change the definition of copyfile in the source code file. It's a ugly solution but works.

def copyfile(src, dest, symlink=True):
                                 |-> change this to False
Share:
15,897

Related videos on Youtube

kjo
Author by

kjo

Updated on September 18, 2022

Comments

  • kjo
    kjo over 1 year

    [I originally posted this question, under a different title, in StackOverflow (here), but later I realized that my problem is very specific to apt-get, hence I am re-posting it here. Sorry for the duplication.]

    I'm trying to install PyQt on Ubuntu (and within a virtualenv). The list of obstacles I'm dealing with is far too long to include here, but the one I'm currently trying to get past is this:

    % workon myvenv
    (myvenv)% cd ~/.virtualenvs/myvenv/build/pyqt
    (myvenv)% python ./configure.py
    Traceback (most recent call last):
      File "./configure.py", line 32, in <module>
        import sipconfig
    

    OK, so let's install sipconfig...

    (myvenv)% pip install SIP
    Downloading/unpacking SIP
      Downloading sip-4.14.8-snapshot-02bdf6cc32c1.zip (848Kb): 848Kb downloaded
      Running setup.py egg_info for package SIP
        Traceback (most recent call last):
          File "<string>", line 14, in <module>
        IOError: [Errno 2] No such file or directory: '/home/yt/.virtualenvs/myvenv/build/SIP/setup.py'
        Complete output from command python setup.py egg_info:
        Traceback (most recent call last):
    
      File "<string>", line 14, in <module>
    
    IOError: [Errno 2] No such file or directory: '/home/yt/.virtualenvs/myvenv/build/SIP/setup.py'
    
    ----------------------------------------
    Command python setup.py egg_info failed with error code 1 in /home/yt/.virtualenvs/myvenv/build/SIP
    Storing complete log in /home/yt/.pip/pip.log
    

    The only recipe I've found so far installing SIP is this

    % python configure.py
    % make
    % sudo make install
    

    ...but this recipe goes against my policy of doing all my Ubuntu installations either through apt-get (or through pip in the case of Python modules).

    Is there some way that I can install SIP with apt-get (and possibly pip)?