I'm on a Mac OSX Lion machine, and I've downloaded wxPython-src-2.9.3.1.tar.bz2. I then did the following (note: output messages have been removed):
$ tar -xjf wxPython-src-2.9.3.1.tar.bz2
$ cd wxPython-src-2.9.3.1
$ mkdir bld
$ cd bld
$ source /path/to/myvirtualenv/bin/activate
(myvirtualenv)$ cross_compiling=yes
(myvirtualenv)$ export MACOSX_DEPLOYMENT_TARGET=10.6.7
(myvirtualenv)$ set arch_flags="-arch ppc64 "
(myvirtualenv)$ ../configure \
--with-mac --enable-monolithic --enable-threads --enable-unicode \
--enable-debug_flag --enable-debug \
--with-libpng --with-libjpeg --with-libtiff --enable-unicode \
--with-opengl --enable-graphics_ctx --with-odbc --enable-gui \
--with-macosx-sdk=/Developer/SDKs/MacOSX10.6.sdk --with-macosx-version-min=10.6 \
CFLAGS="$arch_flags" CXXFLAGS="$arch_flags" CPPFLAGS="$arch_flags" LDFLAGS="$arch_flags" OBJCFLAGS="$arch_flags" OBJCXXFLAGS="$arch_flags" --prefix=/path/to/myvirtualenv/
$ (myvirtualenv)make
$ (myvirtualenv)make install
After that, I did get this message (so I guess it succeeded):
...
------------------------------------------------------
The installation of wxWidgets is finished. On certain
platforms (e.g. Linux) you'll now have to run ldconfig
if you installed a shared library and also modify the
LD_LIBRARY_PATH (or equivalent) environment variable.
wxWidgets comes with no guarantees and doesn't claim
to be suitable for any purpose.
Read the wxWindows Licence on licencing conditions.
------------------------------------------------------
And returned me to my shell. However, I cannot seem to use it
(myvirtualenv)$ python
>>> import wxversion
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named wxversion
Any ideas how I can have it installed in my virtualenv?
wxPython can be installed through apt-get by calling apt-get install python-wxgtk2. 8 or apt-get install python-wxgtk2. 6, depending on which version you want. You may have to call this with root permissions.
enter command : pip install pygame. To install wxpython enter command : pip install -U wxPython.
For others, here is what worked for me:
On Mac OSX, I installed wxpython with Homebrew using:
brew install wxpython
Change into your virtualenv site-packages directory:
cd /venv/lib/python2.7/site-packages
then link the wx.pth
ln -s /usr/local/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/wx.pth wx.pth
and then link the wx-3.0-osx_cocoa directory:
ln -s /usr/local/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/wx-3.0-osx_cocoa wx-3.0-osx_cocoa
after reading through all the above articles, this is the real key:
you need to point your VE at the main python installation.
On my system its:
% ln /Library/Python/2.7/site-packages/wxredirect.pth ./default/lib/python2.7/site-packages/wxredirect.pth
For Windows, you can use the same approach that cweston outlined for OS X, translated to calls to mklink
. I had success creating a virtualenv for an old Python 2.7 / WxPython 2.8 based app by doing the following:
Install WxPython using the installer.
Find the site-packages directory where WxPython was installed. For me,
C:\Python27\Lib\site-packages
Open a shell and change to the site-packages directory inside the virtualenv to which you want to add WxPython, say it's called WxApp
:
cmd
cd C:\Virtualenvs\WxApp\Lib\site-packages
Then create links: hard links for wx.pth and wxversion.py, and a junction for the directory containing the WxPython installation (mine was wx-2.8-msw-unicode
):
mklink /h wx.pth C:\Python27\Lib\site-packages\wx.pth
mklink /h wxversion.py C:\Python27\Lib\site-packages\wxversion.py
mklink /j wx-2.8-msw-unicode C:\Python27\Lib\site-packages\wx-2.8-msw-unicode\
Now I have access to the wx
module:
C:\> C:\VirtualEnvs\WxApp\scripts\activate.bat
(WxApp) C:\>python
ActivePython 2.7.2.5 (ActiveState Software Inc.) based on Python 2.7.2 (default, Jun 24 2011, 12:21:10) [MSC v.1500 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import wx
>>> wx.version()
'2.8.12.1 (msw-unicode)'
>>>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With