Skip to content


Subversion checkout URL

You can clone with
Download ZIP


Pythonbrew + virtualenv: fixup_pth_and_egg_link incorrect paths #315

kylegibson opened this Issue · 0 comments

1 participant



> which virtualenv
> which python
> virtualenv --version

Create a virtual environment

> virtualenv testenv
> source testenv/bin/activate

Install editable package from github

(testenv)> pip install -e git+git://
(testenv)> cat testenv/lib/python2.6/site-packages/nexus.egg-link

The initial egg-link is absolute.

Make the virtualenv relocatable

(testenv)> virtualenv -vv --relocatable testenv
(testenv)> cat testenv/lib/python2.6/site-packages/nexus.egg-link

Egg-link is still absolute.

I have the following code in the fixup_pth_and_egg_link function to display additional information about the environment:

def fixup_pth_and_egg_link(home_dir, sys_path=None):
    """Makes .pth and .egg-link files use relative paths"""
    home_dir = os.path.normcase(os.path.abspath(home_dir))
    if sys_path is None:
        sys_path = sys.path
    logger.debug('paths %s' % sys_path)
    logger.debug('prefix %s' % sys.prefix)
    logger.debug('executable %s' % sys.executable)
    # rest of method ...

Output from the above logging statements:

paths ['/home/kyle/.pythonbrew/pythons/Python-2.6.5/bin', '/home/kyle/.pythonbrew/pythons/Python-2.6.5/lib/python2.6/site-packages/distribute-0.6.24-py2.6.egg', '/home/kyle/.pythonbrew/pythons/Python-2.6.5/lib/', '/home/kyle/.pythonbrew/pythons/Python-2.6.5/lib/python2.6', '/home/kyle/.pythonbrew/pythons/Python-2.6.5/lib/python2.6/plat-linux2', '/home/kyle/.pythonbrew/pythons/Python-2.6.5/lib/python2.6/lib-tk', '/home/kyle/.pythonbrew/pythons/Python-2.6.5/lib/python2.6/lib-old', '/home/kyle/.pythonbrew/pythons/Python-2.6.5/lib/python2.6/lib-dynload', '/home/kyle/.pythonbrew/pythons/Python-2.6.5/lib/python2.6/site-packages', '/home/kyle/.pythonbrew/pythons/Python-2.6.5/lib/python2.6/site-packages/setuptools-0.6c11-py2.6.egg-info']
prefix /home/kyle/.pythonbrew/pythons/Python-2.6.5
executable /home/kyle/.pythonbrew/pythons/Python-2.6.5/bin/python

I would expect the executable to be the python in the new virtualenv, especially given that the top of includes #!/usr/bin/env python

> source testenv/bin/activate
(testenv)> env python
Python 2.6.5 (r265:79063, Dec 16 2011, 19:49:33) 
[GCC 4.4.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> print sys.executable

Workaround #1

Install virtualenv in the new environment, deactivate and activate again

> virtualenv testenv
> source testenv/bin/activate
(testenv)> pip install virtualenv
(testenv)> deactivate
source testenv/bin/activate
(testenv)> pip install -e ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.