Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to install SIP and PyQt on a virtual environment?

I am new to virtualenv. I want to install spyder, which require PyQt4, which requires SIP.

pip doesn't work, so I downloaded SIP, and I did the following commands:

python configure.py
make
make install

But I received this error:

make[1]: entrant dans le répertoire « /stck2/stck2.2/ptoniato/python/pip/virtualenv-1.10.1/provaenv/build/SIP/sipgen »
cp -f sip /stck2/stck2.2/ptoniato/python/pip/virtualenv-1.10.1/provaenv/bin/sip
make[1]: quittant le répertoire « /stck2/stck2.2/ptoniato/python/pip/virtualenv-1.10.1/provaenv/build/SIP/sipgen »
make[1]: entrant dans le répertoire « /stck2/stck2.2/ptoniato/python/pip/virtualenv-1.10.1/provaenv/build/SIP/siplib »
cp -f sip.so /stck2/stck2.2/ptoniato/python/pip/virtualenv-1.10.1/provaenv/lib/python2.7/site-packages/sip.so
strip /stck2/stck2.2/ptoniato/python/pip/virtualenv-1.10.1/provaenv/lib/python2.7/site-packages/sip.so
cp -f /stck2/stck2.2/ptoniato/python/pip/virtualenv-1.10.1/provaenv/build/SIP/siplib/sip.h /usr/local/python/include/python2.7/sip.h
cp: impossible de supprimer « /usr/local/python/include/python2.7/sip.h »: Permission non accordée
make[1]: *** [install] Erreur 1
make[1]: quittant le répertoire « /stck2/stck2.2/ptoniato/python/pip/virtualenv-1.10.1/provaenv/build/SIP/siplib »
make: *** [install] Erreur 2

Impossible de supprimer means Impossible to erase.

I have no root access to this pc. I think that's there is a conflict between the python package that is installed by default on this pc and the virtualenv that I am creating.

How can I resolve the problem?

like image 519
Pierpaolo Avatar asked Nov 08 '13 10:11

Pierpaolo


2 Answers

Here are the steps I used to install sip in my virtualenv. The trick is to make sure that you use the (undocumented?) --always-copy flag, so that it doesn't just symlink the /usr/include/python2.7 directory into your virtualenv.

virtualenv --always-copy ve
. ve/bin/activate
wget http://sourceforge.net/projects/pyqt/files/sip/sip-4.15.4/sip-4.15.4.zip
unzip sip-4.15.4.zip
cd sip-4.15.4
python configure.py --incdir=../ve/include/python2.7
make
make install
cd ..

I was then able to install PyQt4 like so:

wget http://sourceforge.net/projects/pyqt/files/PyQt4/PyQt-4.10.3/PyQt-x11-gpl-4.10.3.tar.gz
tar zxvf PyQt-x11-gpl-4.10.3.tar.gz
cd PyQt-x11-gpl-4.10.3
python configure.py
make
make install

This did give an error at the end, but it was ignored. I think this is just part of installing 'designer' which isn't critical.

install: cannot create regular file `/usr/lib/x86_64-linux-gnu/qt4/plugins/designer/libpyqt4.so': Permission denied
make[1]: [install_target] Error 1 (ignored)
like image 193
Ellis Percival Avatar answered Oct 30 '22 13:10

Ellis Percival


make sure that you have your virtualenv active. With both pyenv and pyenv-virtualenv installed you can quickly follow these commands.

I just installed both SIP and PyQt4 succesfully on a newly created virtualenv:

pyenv virtualenv testenvironment
pyenv rehash
pyenv shell testenvironment
cd ~/.pyenv/versions/testenvironment/
pip install --no-install sip #fails but do not worry
cd build/sip/
python configure.py #--incdir=~/.pyenv/versions/testenvironment/include/python2.7 may be needed
make
make install
cd ../../

Then you are ready to download and install PyQt4. You have to do it manually. Go to the PyQt4 page and get the latest version in the working folder, unpack it and you are ready to go again with configure/make/make install.

Test if by importing some PyQt4 packages in a python interactive session:

>>> from PyQt4 import QtCore, QtGui
like image 40
Enucatl Avatar answered Oct 30 '22 13:10

Enucatl