cpvirtualenv and global python site-packages

189 views
Skip to first unread message

Guandalino

unread,
Jun 24, 2011, 6:34:17 PM6/24/11
to virtuale...@googlegroups.com
$ mkvirtualenv --no-site-packages foo
(foo)$ pip freeze
wsgiref==0.1.2

Now replicate foo using cpvirtualenv.

(foo)$ cpvirtualenv foo bar
(bar)$ pip freeze
Brlapi==0.5.5
CouchDB==0.8
GnuPGInterface==0.3.2
Jinja2==2.5.5
Mako==0.3.6

It seems cpvirtualenv is also including packages from the system wide installation, though it's not true because "additional" modules are not importable when bar is active.

(bar)$ python
>>> import mako
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named mako

What am I missing?

Doug Hellmann

unread,
Jul 3, 2011, 7:59:37 AM7/3/11
to virtuale...@googlegroups.com

After the environment is copied, it is made "relocatable" using virtualenv. That might change the setting for whether the global site-packages should be included in the search.

Does running toggleglobalsitepackages in the new environment fix the problem?

If not, where is pip installed? Which version of pip is being used after bar is activated?

Doug

D. Guandalino

unread,
Jul 3, 2011, 10:03:23 AM7/3/11
to virtuale...@googlegroups.com
2011/7/3 Doug Hellmann <doug.h...@gmail.com>:

Hi Doug.

> Does running toggleglobalsitepackages in the new environment fix the problem?

Nope it doesn't.

(foo)$ cpvirtualenv foo bar
(bar)$ pip freeze

...long list of packages...

(bar)$ toggleglobalsitepackages
Enabled global site-packages
(bar)$ pip freeze
... the same long list of packages as before...

(bar)$ toggleglobalsitepackages
Disabled global site-packages
(bar)$ pip freeze
... the same long list of packages as before...

> If not, where is pip installed? Which version of pip is being used after bar is activated?

I don't have pip installed globally. Each virtual environment has its
own pip like so:

(bar)$ pip --version
pip 1.0.1 from ~/development/python/tk/envs/django_cms/bar/lib/python2.7/site-packages/pip-1.0.1-py2.7.egg
(python 2.7)

I guess this pip is a copy of the one that comes along with virtualenv
(I'm using v1.6.1).

HTH, many thanks for your support.

Best regards

Doug Hellmann

unread,
Jul 3, 2011, 12:50:29 PM7/3/11
to virtuale...@googlegroups.com

On Jul 3, 2011, at 10:03 AM, D. Guandalino wrote:

> 2011/7/3 Doug Hellmann <doug.h...@gmail.com>:
>
> Hi Doug.
>
>> Does running toggleglobalsitepackages in the new environment fix the problem?
> Nope it doesn't.
>
> (foo)$ cpvirtualenv foo bar
> (bar)$ pip freeze
> ...long list of packages...
>
> (bar)$ toggleglobalsitepackages
> Enabled global site-packages
> (bar)$ pip freeze
> ... the same long list of packages as before...
>
> (bar)$ toggleglobalsitepackages
> Disabled global site-packages
> (bar)$ pip freeze
> ... the same long list of packages as before...

This looks like a bug of some sort, then. I'm still not sure where it is, but would you open a ticket in the bug tracker for virtualenvwrapper (https://bitbucket.org/dhellmann/virtualenvwrapper/issues)? That will make sure I don't lose track of the details until I have a chance to determine if it is in cpvirtualenv or something it does to the environment after copying it.

>
>> If not, where is pip installed? Which version of pip is being used after bar is activated?
>
> I don't have pip installed globally. Each virtual environment has its
> own pip like so:
>
> (bar)$ pip --version
> pip 1.0.1 from ~/development/python/tk/envs/django_cms/bar/lib/python2.7/site-packages/pip-1.0.1-py2.7.egg
> (python 2.7)

OK, it was worth checking the easy stuff first. :-)

Guandalino

unread,
Jul 3, 2011, 4:53:00 PM7/3/11
to virtuale...@googlegroups.com
I filed the bug report, with a wrong title that I can't edit.. damn. Anyway, https://bitbucket.org/dhellmann/virtualenvwrapper/issue/102/https-groupsgooglecom-d-topic

Finally, I don't know if that matters but I'm using Ubuntu. There, Python packages are kept in dist-packages instead of site-packages.

Doug Hellmann

unread,
Jul 3, 2011, 5:50:55 PM7/3/11
to virtuale...@googlegroups.com

On Jul 3, 2011, at 4:53 PM, Guandalino wrote:

> I filed the bug report, with a wrong title that I can't edit.. damn. Anyway, https://bitbucket.org/dhellmann/virtualenvwrapper/issue/102/https-groupsgooglecom-d-topic

I don't see a way to edit the title either, but that's OK. I know what it means.

> Finally, I don't know if that matters but I'm using Ubuntu. There, Python packages are kept in dist-packages instead of site-packages.

I'm not sure if it would matter, but that's good to know.

Reply all
Reply to author
Forward
0 new messages