I have installed wxPython by following the instructions from this answer using the following command in Ubuntu 14.04
sudo apt-get install python-wxgtk2.8 python-wxtools wx2.8-doc wx2.8-examples wx2.8-headers wx2.8-i18n
Everything got installed properly.
But when I do import wx in my code, I get the following error.
Python 2.7.6 (default, Mar 22 2014, 22:59:38)
[GCC 4.8.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import wx
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named wx
Do I have to install anything to use wxPython in my code?
Edit:
The directory in which wxPython is installed is in sys.path
$ pip show wxPython-common
---
Metadata-Version: 1.1
Name: wxPython-common
Version: 3.0.0.0
Summary: Cross platform GUI toolkit for Python
Home-page: http://wxPython.org/
Author: Robin Dunn
Author-email: Robin Dunn <[email protected]>
License: wxWidgets Library License (LGPL derivative)
Location: /usr/lib/python2.7/dist-packages
Requires:
From the above output we can see that it is installed in /usr/lib/python2.7/dist-packages and when I print sys.path this path is included.
$ python
Python 2.7.6 (default, Mar 22 2014, 22:59:38)
[GCC 4.8.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> print sys.path
['', '/usr/lib/python2.7', '/usr/lib/python2.7/plat-i386-linux-gnu', '/usr/lib/python2.7/lib-tk', '/usr/lib/python2.7/lib-old', '/usr/lib/python2.7/lib-dynload', '/usr/local/lib/python2.7/dist-packages', '/usr/lib/python2.7/dist-packages', '/usr/lib/python2.7/dist-packages/PILcompat', '/usr/lib/python2.7/dist-packages/gst-0.10', '/usr/lib/python2.7/dist-packages/gtk-2.0', '/usr/lib/pymodules/python2.7', '/usr/lib/python2.7/dist-packages/ubuntu-sso-client']
Edit2:
I have also made sure that I am using the correct version of python.
~$ which python
/usr/bin/python
~$ ll /usr/bin/python
lrwxrwxrwx 1 root root 9 Dec 21 2013 /usr/bin/python -> python2.7*