I am using Enthought Python Distribution (7.2, 64-bit). It comes without wxPython (which is quite important). However, wxPython-2.9 seems to support 64-bit Cocoa interface, so I gave it a try. Actually, it all went good: the command
python build-wxpython.py --osx_cocoa --mac_framework --install
successfully compiled, and even got into EPD site-packages. However, a simple wxPython code
import wx
wx.App()
fails with the following error:
This program needs access to the screen.
Please run with a Framework build of python, and only when you are
logged in on the main display of your Mac.
Can you give me some advice how to cure this? EPD is clearly a Python Framework (i.e., looking at /Library/Frameworks/EPD64.framework and /Library/Frameworks/Python.framework convinces me in it) but this wxPython build does not know about that. The version of wxPython is 2.9.3.1
Using a wrapper script like this should setup your environment in such a way that wxPython works correctly:
#!/bin/bash
# Real Python executables to use
PYVER=2.7
PYTHON=/Library/Frameworks/Python.framework/Versions/$PYVER/bin/python$PYVER
# Figure out the root of your EPD env
ENV=`$PYTHON -c "import os; print os.path.abspath(os.path.join(os.path.dirname(\"$0\"), '..'))"`
# Run Python with your env set as Python's PYTHONHOME
export PYTHONHOME=$ENV
exec $PYTHON "$@"
Just dump it in a file, give it executable permission and use it to launch your wxPython app instead of the python executable.
It's because you install wxpython
with system python. so you can just modify the main.py
or whatever the other main point your project defined, add at the head like the following:
import site
site.addsitedir("/Users/jazz/.pyenv/versions/py27/lib/python2.7/site-packages/")
and then run with /usr/bin/python
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