Re: [wxpython-users] import wx behaviour on Ubuntu

6 views
Skip to first unread message

Federico Fanton

unread,
May 22, 2009, 12:44:23 PM5/22/09
to wxpytho...@lists.wxwidgets.org
Stani wrote:
> I would have expected that 2.8 would be the default, but of course
> this is debatable. Is this intended behaviour? Is there a way to set
> system wide the preference for 2.8 instead of 2.6? Robin, does Ubuntu
> implement this differently from upstream wxpython?

This used to work as expected in Ubuntu < 9.04...

Under Jaunty things are different, because every wxpython package adds a
wx-2.[68]-gtk2-unicode.pth to /usr/lib/python2.6/dist-packages, so - if
I understand it correctly - on a "import wx" Python chooses
alphabetically, thus the 2.6 version..

I worked around it by removing those .pth's and keeping a simple wx.pth
containing "wx-2.8-gtk2-unicode".

I don't know if there's an "official" way of doing it :)

Bye!

Stani

unread,
May 22, 2009, 12:14:32 PM5/22/09
to wxpython-users
When I have both python-wxgtk2.6 and python-wxgtk2.8 installed on
ubuntu and I do a normal "import wx", it chooses by default 2.6:
$ python
Python 2.6.2 (release26-maint, Apr 19 2009, 01:58:18)
[GCC 4.3.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import wx
>>> wx.VERSION
(2, 6, 3, 2, '')

I would have expected that 2.8 would be the default, but of course
this is debatable. Is this intended behaviour? Is there a way to set
system wide the preference for 2.8 instead of 2.6? Robin, does Ubuntu
implement this differently from upstream wxpython?

Best regards,
Stani

--
Phatch Photo Batch Processor - http://photobatch.stani.be
SPE Python IDE - http://pythonide.stani.be

Robin Dunn

unread,
May 22, 2009, 5:46:39 PM5/22/09
to wxpytho...@lists.wxwidgets.org

You're supposed to be able to use update-alternatives to switch between
which wx.pth file is installed in [site|dist]-packages, but if Ubuntu
has changed how that file is installed and managed then that feature is
probably broken.

--
Robin Dunn
Software Craftsman
http://wxPython.org

Robin Dunn

unread,
May 22, 2009, 5:56:19 PM5/22/09
to wxpytho...@lists.wxwidgets.org
Stani wrote:
> On Fri, May 22, 2009 at 8:10 PM, Conrado Porto Lopes Gouvęa
> <conra...@gmail.com> wrote:

>> On Fri, May 22, 2009 at 13:14, Stani <spe.st...@gmail.com> wrote:
>>> I would have expected that 2.8 would be the default, but of course
>>> this is debatable. Is this intended behaviour? Is there a way to set
>>> system wide the preference for 2.8 instead of 2.6?
>> http://wiki.wxpython.org/MultiVersionInstalls
>>
>> If you want to change the system wide default, I think you can edit
>> the wx.pth file.
> This is strange, the contents of wx.pth is:
> wx-2.8-gtk2-unicode
>
> So probably Federico Fanton is right, although I would expect that
> alphabetically wx.pth would preceed wx-2.6-gtk2-unicode.pth
> alphabetically.
>
> Is there a way to set this as a user instead of system-wide (which
> requires root privileges)?

I think dirs in the PYTHONPATH env variable are put in the sys.path
before dirs specified in .pth files.

Robin Dunn

unread,
May 22, 2009, 6:14:08 PM5/22/09
to wxpytho...@lists.wxwidgets.org
Stani wrote:
> Could you give the full command? I don't know the argument, eg it is
> clearly not:
> sudo update-alternatives python-wxgtk
>

It should be something like:

sudo update-alternatives --set NAME DEST

Where NAME is some link in /etc/alternatives (used to be just wx.pth,
but now I think it is something like wx$PYVER.pth) and DEST is the file
that it should be linked to. My packages install the DEST files in
/usr/lib/wx/python$PYVER/wx$WXVER.pth. I'm not sure if the Ubuntu
packages follow the same pattern any more, or even if they are still
using update-alternatives for that .pth file. (And I don't have an
untweaked Ubuntu box handy to check.)

Conrado Porto Lopes Gouvêa

unread,
May 22, 2009, 2:10:38 PM5/22/09
to wxpytho...@lists.wxwidgets.org
On Fri, May 22, 2009 at 13:14, Stani <spe.st...@gmail.com> wrote:
> I would have expected that 2.8 would be the default, but of course
> this is debatable. Is this intended behaviour? Is there a way to set
> system wide the preference for 2.8 instead of 2.6?

http://wiki.wxpython.org/MultiVersionInstalls

If you want to change the system wide default, I think you can edit
the wx.pth file.

Conrado

Stani

unread,
May 22, 2009, 5:49:09 PM5/22/09
to wxpytho...@lists.wxwidgets.org
This is strange, the contents of wx.pth is:
wx-2.8-gtk2-unicode

So probably Federico Fanton is right, although I would expect that
alphabetically wx.pth would preceed wx-2.6-gtk2-unicode.pth
alphabetically.

Is there a way to set this as a user instead of system-wide (which
requires root privileges)?

Stani

unread,
May 22, 2009, 5:52:46 PM5/22/09
to wxpytho...@lists.wxwidgets.org
On Fri, May 22, 2009 at 11:46 PM, Robin Dunn <ro...@alldunn.com> wrote:
Could you give the full command? I don't know the argument, eg it is
clearly not:
sudo update-alternatives python-wxgtk

--

Stani

unread,
May 22, 2009, 7:12:14 PM5/22/09
to wxpytho...@lists.wxwidgets.org
On Sat, May 23, 2009 at 12:14 AM, Robin Dunn <ro...@alldunn.com> wrote:
> It should be something like:
>
>    sudo update-alternatives --set NAME DEST
>
> Where NAME is some link in /etc/alternatives (used to be just wx.pth, but
> now I think it is something like wx$PYVER.pth) and DEST is the file that it
> should be linked to.  My packages install the DEST files in
> /usr/lib/wx/python$PYVER/wx$WXVER.pth.  I'm not sure if the Ubuntu packages
> follow the same pattern any more, or even if they are still using
> update-alternatives for that .pth file.  (And I don't have an untweaked
> Ubuntu box handy to check.)

Well, very strange, if I do:
$ ls /etc/alternatives | grep wx
wx2.5.pth
wx2.6.pth

$ sudo update-alternatives --config wx2.6.pth
[sudo] password for stani:

Er zijn 2 alternatieven die 'wx2.6.pth' voorzien.

Selectie Alternatieven
-----------------------------------------------
*+ 1 /usr/lib/wx/python/wx2.8.pth
2 /usr/lib/wx/python/wx2.6.pth

It shows that 2.8 is already the default for wx2.6.pth

I noticed a bug, that in sys.path both 2.6 and 2.8 were present, so I
reported it here:
https://bugs.launchpad.net/ubuntu/+source/wxwidgets2.8/+bug/379573

Reply all
Reply to author
Forward
0 new messages