如何在virtualenv中安装wxPython

Fra*_*See 9 python windows macos wxpython virtualenv

我在Mac OSX Lion机器上,我已经下载了wxPython-src-2.9.3.1.tar.bz2.然后我做了以下(注意:输出消息已被删除):

$ 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
Run Code Online (Sandbox Code Playgroud)

在那之后,我确实收到了这条消息(所以我猜它成功了):

...
 ------------------------------------------------------

 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.

 ------------------------------------------------------
Run Code Online (Sandbox Code Playgroud)

然后把我送回了我的贝壳.但是,我似乎无法使用它

(myvirtualenv)$ python
>>> import wxversion
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named wxversion
Run Code Online (Sandbox Code Playgroud)

我有什么想法可以在我的virtualenv中安装它?

cwe*_*ton 8

对于其他人来说,这对我有用:

在Mac OSX上,我使用Homebrew安装了wxpython:

brew install wxpython
Run Code Online (Sandbox Code Playgroud)

转到virtualenv site-packages目录:

cd /venv/lib/python2.7/site-packages
Run Code Online (Sandbox Code Playgroud)

然后链接wx.pth

ln -s /usr/local/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/wx.pth wx.pth
Run Code Online (Sandbox Code Playgroud)

然后链接wx-3.0-osx_cocoa目录:

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
Run Code Online (Sandbox Code Playgroud)


rbp*_*rbp 3

读完以上所有文章后,这才是真正的关键:

你需要将你的 VE 指向主要的 python 安装。

在我的系统上它是:

% ln /Library/Python/2.7/site-packages/wxredirect.pth ./default/lib/python2.7/site-packages/wxredirect.pth