15

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?

nbro
  • 15,395
  • 32
  • 113
  • 196
Pierpaolo
  • 1,721
  • 4
  • 20
  • 34
  • Just follow this Link: http://stackoverflow.com/questions/1961997/is-it-possible-to-add-pyqt4-pyside-packages-on-a-virtualenv-sandbox – jokober Apr 08 '14 at 12:40

2 Answers2

19

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)
nbro
  • 15,395
  • 32
  • 113
  • 196
Ellis Percival
  • 4,632
  • 2
  • 24
  • 34
  • 2
    Using Ubuntu 14.10, python3.4 and last version of sip and pyqt at the time of sriting this, I had to use an absolute path for incdir while compiling sip (/home/username/.virtualenvs/ve/include/python3.4). For PyQt I had to use the --sip-incdir option with the same (absolute) path. Also, grab some coffee and a bit of patience since PyQt is __big__ it took a while to compile over here. – thomas Nov 02 '14 at 08:01
  • I'd like to add that the --incdir part of "python configure.py --incdir..." is what was necessary for me to remove the "permission denied errors," and also resulted in "import sipconfig" and "import sip" working. When "--incdir.." was omitted, only "import sip" worked – user3391229 May 21 '15 at 02:54
  • Hey all! I am trying to do this install in a virtualenv but am running into an issue. The SIP install went ok. I install SIP version 4.19.2. When I go to run configure for PyQt 4.12, I get the error "Error: This version of PyQt requires SIP v4.19.0 or later". I tried running with --incdir set to the include dir without success. Am I missing a step? – jspada Apr 11 '17 at 18:26
7

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
Enucatl
  • 507
  • 3
  • 14