pyside / PySide

ATTENTION: This project is deprecated, please refer to PySide2
https://wiki.qt.io/PySide2
GNU Lesser General Public License v2.1
291 stars 66 forks source link

ImportError when moving relocatable virtualenv (Linux only) #133

Closed fredrikaverpil closed 8 years ago

fredrikaverpil commented 8 years ago

First I create a virtualenv and pip install PySide into it.

fredrik@ubuntudev:~/virtualenvs$ virtualenv --always-copy myenv
New python executable in myenv/bin/python
Installing setuptools, pip, wheel...done.
fredrik@ubuntudev:~/virtualenvs$ source myenv/bin/activate
(myenv)fredrik@ubuntudev:~/virtualenvs$ pip install PySide
Collecting PySide
Installing collected packages: PySide
Successfully installed PySide-1.2.4

PySide works fine:

fredrik@ubuntudev:~/virtualenvs$ source myenv/bin/activate
(myenv)fredrik@ubuntudev:~/virtualenvs$ python
Python 2.7.6 (default, Jun 22 2015, 17:58:13) 
[GCC 4.8.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from PySide import QtCore

Then I deactivate, make the virtualenv relocatable and move the virtualenv. The PySide module is not found:

(myenv)fredrik@ubuntudev:~/virtualenvs$ deactivate
fredrik@ubuntudev:~/virtualenvs$ virtualenv --relocatable myenv
Making script myenv/bin/pip2.7 relative
Making script myenv/bin/wheel relative
Making script myenv/bin/easy_install-2.7 relative
Making script myenv/bin/pyside-uic relative
Making script myenv/bin/easy_install relative
Making script myenv/bin/pip2 relative
Making script myenv/bin/pip relative
fredrik@ubuntudev:~/virtualenvs$ mv myenv movedenv
fredrik@ubuntudev:~/virtualenvs$ source movedenv/bin/activate
(myenv)fredrik@ubuntudev:~/virtualenvs$ python
Python 2.7.6 (default, Jun 22 2015, 17:58:13) 
[GCC 4.8.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from PySide import QtCore
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named PySide
>>> 

However, if I specify the full path to the virtualenv's python executable, the PySide module is found:

(myenv)fredrik@ubuntudev:~/virtualenvs$ movedenv/bin/python
Python 2.7.6 (default, Jun 22 2015, 17:58:13) 
[GCC 4.8.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from PySide import QtCore
>>>

This is all on Ubuntu 14.04.3 and I do no see this behavior on OS X or Windows.

fredrikaverpil commented 8 years ago

Actually, this might be a virtualenv issue rather than a PySide issue.

It seems pip list is returning whatever is installed in the system-wide python/pip when "activated" in a relocated virtualenv. However, if the full path to the virtualenv's pip is specified, pip list will return the modules only installed into the virtualenv.

I will close the issue in this repository.