Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

PYTHONPATH and eggs

0 views
Skip to first unread message

geoffbache

unread,
Mar 3, 2010, 5:14:08 AM3/3/10
to
Hi all,

I have a very simple problem that seems to have no simple solution.

I have a module which is installed centrally and lives in a Python
egg. I have experimented with some minor changes to it and would like
to set my PYTHONPATH to pick up my local copy of it, but don't want to
have to figure out how to build my own version of the "egg" if
possible.

Unfortunately, the location from PYTHONPATH ends up after the eggs in
sys.path so I can't persuade Python to import my version. The only way
I've found to fix it is to copy the main script and manually hack
sys.path at the start of it which isn't really very nice. I wonder if
there is any better way as I can't be the first person to want to do
this, surely?

I've seen this issue has been discussed elsewhere and flagged as a
problem (e.g.
http://mail.python.org/pipermail/distutils-sig/2009-January/010755.html)

but I've been unable to find any suggestions for workarounds or
indications whether this will be/has been fixed.

Regards,
Geoff Bache

Jonathan Gardner

unread,
Mar 3, 2010, 7:10:14 PM3/3/10
to geoffbache, pytho...@python.org

Sounds like you might need to use virtualenv to setup python
environments that you can control.

--
Jonathan Gardner
jgar...@jonathangardner.net

David Cournapeau

unread,
Mar 3, 2010, 9:24:24 PM3/3/10
to geoffbache, pytho...@python.org
On Wed, Mar 3, 2010 at 7:14 PM, geoffbache <geoff...@jeppesen.com> wrote:

> Unfortunately, the location from PYTHONPATH ends up after the eggs in
> sys.path so I can't persuade Python to import my version. The only way
> I've found to fix it is to copy the main script and manually hack
> sys.path at the start of it which isn't really very nice. I wonder if
> there is any better way as I can't be the first person to want to do
> this, surely?

One way is to never install things as eggs: I have a script
hard_install which forces things to always install with
--single-externally-managed blablabla. This has worked very well for
me, but may not always be applicable (in particular if you are on a
platform where building things from sources is difficult).

cheers,

David

geoffbache

unread,
Mar 4, 2010, 3:20:57 AM3/4/10
to

On Mar 4, 3:24 am, David Cournapeau <courn...@gmail.com> wrote:

Thanks for the tips. Is your script generic at all? I wonder if you'd
be prepared to share it?

Figuring out virtualenv would also be an option, as would figuring out
how to build my own egg, but both these solutions feel like overkill
to me just to enable a small bit of tweaking.

/Geoff

0 new messages