Bug 739275 - pip-python not playing nice with virtualenv
Summary: pip-python not playing nice with virtualenv
Keywords:
Status: CLOSED CANTFIX
Alias: None
Product: Fedora
Classification: Fedora
Component: python-pip
Version: 15
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Tim Flink
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2011-09-17 05:28 UTC by Jorge Gallegos
Modified: 2011-09-18 00:43 UTC (History)
2 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2011-09-17 23:03:12 UTC


Attachments (Terms of Use)

Description Jorge Gallegos 2011-09-17 05:28:15 UTC
Description of problem:

pip is supposed to be able to create a virtualenv in one go with the -E option (or work with an existing virtualenv), however this doesn't work as it throws an import error about peak. Creating a virtualenv separately and then using that v-env pip script works. The pip package is a bit outdated (current version is 1.0.2), but I'm not sure if packaging the newest version would fix this issue. It would help nonetheless.


Version-Release number of selected component (if applicable):

Name        : python-pip
Arch        : noarch
Version     : 0.8.3
Release     : 1.fc15

Name        : python-virtualenv
Arch        : noarch
Version     : 1.5.1
Release     : 2.fc15


How reproducible:
Always.

Steps to Reproduce:
1. Try to install anything with /usr/bin/pip-python -E <path>
2.
3.
  
Actual results:
$ /usr/bin/pip-python --version
pip 0.8.3 from /usr/lib/python2.7/site-packages (python 2.7)
$ /usr/bin/pip-python -E /tmp/venv install bottle
Creating new virtualenv environment in /tmp/venv
  New python executable in /tmp/venv/bin/python
  Installing setuptools...done.....................
Traceback (most recent call last):
  File "/usr/lib/python2.7/site-packages/pip/runner.py", line 16, in <module>
    exit = run()
  File "/usr/lib/python2.7/site-packages/pip/runner.py", line 11, in run
    import pip
  File "/usr/lib/python2.7/site-packages/pip/__init__.py", line 9, in <module>
    from pip.basecommand import command_dict, load_command, load_all_commands, command_names
  File "/usr/lib/python2.7/site-packages/pip/basecommand.py", line 12, in <module>
    from pip.baseparser import parser, ConfigOptionParser, UpdatingDefaultsHelpFormatter
  File "/usr/lib/python2.7/site-packages/pip/baseparser.py", line 5, in <module>
    import pkg_resources
  File "/usr/lib/python2.7/site-packages/pkg_resources.py", line 2691, in <module>
    add_activation_listener(lambda dist: dist.activate())
  File "/usr/lib/python2.7/site-packages/pkg_resources.py", line 668, in subscribe
    callback(dist)
  File "/usr/lib/python2.7/site-packages/pkg_resources.py", line 2691, in <lambda>
    add_activation_listener(lambda dist: dist.activate())
  File "/usr/lib/python2.7/site-packages/pkg_resources.py", line 2195, in activate
    map(declare_namespace, self._get_metadata('namespace_packages.txt'))
  File "/usr/lib/python2.7/site-packages/pkg_resources.py", line 1776, in declare_namespace
    __import__(parent)
ImportError: No module named peak


Expected results:
A virtual environment in /tmp/venv with the requested package installed (in the example above: bottle)

Additional info:

This works, however:

$ /usr/bin/virtualenv /tmp/venv
New python executable in /tmp/venv/bin/python
Installing setuptools............................done.

$ /usr/bin/pip-python -E /tmp/venv install bottle
Downloading/unpacking bottle
  Downloading bottle-0.9.6.tar.gz (45Kb): 45Kb downloaded
  Running setup.py egg_info for package bottle
    
Installing collected packages: bottle
  Running setup.py install for bottle
    
Successfully installed bottle
Cleaning up...


But if you use the --no-site-packages, it b0rks:


$ /usr/bin/virtualenv --no-site-packages /tmp/venv
New python executable in /tmp/venv/bin/python
Installing setuptools............................done.

$ /usr/bin/pip-python -E /tmp/venv install bottle
Traceback (most recent call last):
  File "/usr/lib/python2.7/site-packages/pip/runner.py", line 16, in <module>
    exit = run()
  File "/usr/lib/python2.7/site-packages/pip/runner.py", line 11, in run
    import pip
  File "/usr/lib/python2.7/site-packages/pip/__init__.py", line 9, in <module>
    from pip.basecommand import command_dict, load_command, load_all_commands, command_names
  File "/usr/lib/python2.7/site-packages/pip/basecommand.py", line 12, in <module>
    from pip.baseparser import parser, ConfigOptionParser, UpdatingDefaultsHelpFormatter
  File "/usr/lib/python2.7/site-packages/pip/baseparser.py", line 5, in <module>
    import pkg_resources
  File "/usr/lib/python2.7/site-packages/pkg_resources.py", line 2691, in <module>
    add_activation_listener(lambda dist: dist.activate())
  File "/usr/lib/python2.7/site-packages/pkg_resources.py", line 668, in subscribe
    callback(dist)
  File "/usr/lib/python2.7/site-packages/pkg_resources.py", line 2691, in <lambda>
    add_activation_listener(lambda dist: dist.activate())
  File "/usr/lib/python2.7/site-packages/pkg_resources.py", line 2195, in activate
    map(declare_namespace, self._get_metadata('namespace_packages.txt'))
  File "/usr/lib/python2.7/site-packages/pkg_resources.py", line 1776, in declare_namespace
    __import__(parent)
ImportError: No module named peak

Strangely enough, using the virtualenv's pip script works even with --no-site-packages, and the version is older:

$ /tmp/venv/bin/pip --version
pip 0.8.1 from /tmp/venv/lib/python2.7/site-packages/pip-0.8.1-py2.7.egg (python 2.7)

$ /tmp/venv/bin/pip freeze
wsgiref==0.1.2

$ /tmp/venv/bin/pip install bottle
Downloading/unpacking bottle
  Downloading bottle-0.9.6.tar.gz (45Kb): 45Kb downloaded
  Running setup.py egg_info for package bottle
    
Installing collected packages: bottle
  Running setup.py install for bottle
    
Successfully installed bottle
Cleaning up...

$ /tmp/venv/bin/pip freeze
bottle==0.9.6
wsgiref==0.1.2

Comment 1 Tim Flink 2011-09-17 23:03:12 UTC
Actually, the -E option is known to be broken and will be removed from the next release of pip [1]. Their rationale is that recent versions of virtualenv all have a version of pip installed and it's better to just activate the virtualenv before installing packages instead of running an external version of pip on them.

Since there is no fix available from upstream and they are removing the -E feature, I'm closing this as CANTFIX.

If you're interested in the newer pip on fedora 15, I can make an f15 build available outside of yum when I update f16 but at this point, I'm not planning to update the f15 version from 0.8.3 because there were significant changes from 0.8.3 -> 1.0.x.

[1] http://www.pip-installer.org/en/latest/news.html#develop-unreleased

Comment 2 Jorge Gallegos 2011-09-18 00:43:59 UTC
Interesting, I didn't know they were dropping -E, but yeah I agree it makes sense. I have no urgency/need to use a newer version of pip in fedora 15, and even so I could just use a virtualenv and upgrade that pip :)

Thanks for the clarification!


Note You need to log in before you can comment on or make changes to this bug.