I tried the first post on wxpython by fuse. The code is as follows

#
import wx
#
# always add this line, or your code won't compile - the wx module contains the GUI code you'll use
#
"""The start of our wxPython GUI tutorial"""
#

#
app = wx.App(redirect=False) # create a wx application
#

#
window = wx.Frame(None, title = 'Sample GUI App') # create a window
#
btn = wx.Button(window)
#
# create a button 'widget' on the window - note how the button receives the window. This creates a tree-like structure where the window is the parent node and anything else like buttons are child nodes.
#

#
window.Show() # make the frame (and hence button) visible
#
app.MainLoop() # keep things going]

But when i tried to execute it i am getting the following error

surai@napster:~$ python first.py
Traceback (most recent call last):
File "first.py", line 2, in <module>
import wx
File "/usr/lib/python2.5/site-packages/wx-2.8-gtk2-unicode/wx/__init__.py", line 45, in <module>
from wx._core import *
File "/usr/lib/python2.5/site-packages/wx-2.8-gtk2-unicode/wx/_core.py", line 6, in <module>
new_instancemethod = new.instancemethod
AttributeError: 'module' object has no attribute 'instancemethod'
surai@napster:~$


No matter what ever code i type i am getting the same error. Please provide me some suitable to suggestion to overcome them.

Let's hope your code does not look like the one you showed. Try to run just this ...

import wx

If a similar error message comes up, then there is something wrong with your wxPython installation.

Yes i am getting the same error. Any suggestion to remove and reinstall the wxpython. I installed in the ubuntu 8.04.

I don't have a chance to use Linux much, so I am not very familiar with the uninstall/reinstall procedure on this great operating system. There are quite a number of Linux users on this forum, hope they take a look. You may simply start a new post and title it "How to uninstall/reinstall wxPython on Linux?".

My initial guess would be to use the Synaptic package manager.

Thanks for the time taken to reply. Hoping to get reply from others

I haven't done this in forever, and I'm not on a linux machine at the moment, but I'll try to say what I remembered doing :P

If you originally installed it using "sudo apt-get install ...." then you may have not installed any other packages it requires to run.

I would use the package manager GUI instead of the terminal commands because I don't know the package name for wxpython off the top of my head, and the GUI will auto-tick all the dependencies. Search for "wx" in the GUI and when it populates the list with the results, find your wxpython package that you installed and remove it and any dependencies.

Let that finish uninstalling and then open the Synaptic GUI again and search 'wx'. Then find the wxpython package that fits your version of Python (if you're not sure what Python you have, just type "python" in the terminal to get to the interactive shell, which should list the version number in the first line). Check the wxpython package and if it asks about other dependencies, allow it to check those for installation too. Then let it do its thing, and wxpython should work after that!

I will try to get onto an Ubuntu machine within the next 30 minutes or so, and from there I'll edit this with a better description, as I know this is my recollection and it's too vague.

commented: thanks for helping out +12

Ok, I couldn't edit the above post, but here's the steps to follow:

1. You'll need to add the repository key to the api's list of trusted keys in order to get the wxpython packages. To do this, first install curl by using the command sudo apt-get install curl . Let this install, and then proceed to add the key via curl [url]http://apt.wxwidgets.org/key.asc[/url] | sudo apt-key add - .

2. Go to System > Administration > Software Sources and click on the Third-Party Software tab. Click the "Add" button and put deb [url]http://apt.wxwidgets.org/[/url] hardy-wx main then click "Add Source". Then, click "Add" again and this time, put in deb-src [url]http://apt.wxwidgets.org/[/url] hardy-wx main . When you've done this, click the "Close" button in the lower right. It should ask about updating/refreshing or downloading new packages, so let it do it that.

3. Update your local packages with sudo apt-get update .

4. Get and install wxpython and its dependencies with sudo apt-get install python-wxgtk2.8 python-wxtools wx2.8-i18n .

Once this is all done, try the command python and once in the interactive shell, type import wx . If it does this without any errors, then you've successfully got it! Hope that helped! :D

Hey thanks man. It worked.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.