Wx cannot work on Mac

I installed anaconda instead of system python on mac, but when I print

import wx
app = wx.App()

I got it:

This program needs access to the screen. Run the python build using the Framework and only when you log in to your Mac’s main display.

I am using a script :

#!/bin/bash

# what real Python executable to use
PYVER=2.7
PYTHON=/Library/Frameworks/Python.framework/Versions/$PYVER/bin/python$PYVER

# find the root of the virtualenv, it should be the parent of the dir this script is in
ENV=`$PYTHON -c "import os; print os.path.abspath(os.path.join(os.path.dirname(\"$0\"), '..'))"`

# now run Python with the virtualenv set as Python HOME
export PYTHONHOME=$ENV 
exec $PYTHON "$@"

but he just used the python system. Do not use lib in anaconda. I want to use wx GUI in anaconda, how to solve the problem?

+4
source share
1 answer

I fixed the problem for my Python 2 and 3 virtual envs by reading this post (see my tip in the following):

My environment:

  • macOS 10.12.5
  • Python 2, Homebrew
    • wxPython : brew wxpython
  • Python 3, Homebrew
    • wxPython : gpip3 install wxpython ( PIP Python 3)

:

  • script Python 3.
  • "PYTHONHOME" "" "postactivate", virtualenvwrapper.
+2

Source: https://habr.com/ru/post/1657447/


All Articles