pip install flask --upgarde
export FLASK_APP=app.py; flask run
Why is that happening?
python executables in El Capitan spawns
.../Python.framework/Versions/2.7/Resources/Python.app + some extra magic. The problem is that the framework bundle doesn't have its own signature, and it uses signatures of parent application binaries.
How to check?
The first thing to check after installing applications from non-Apple-maintained-source-that-might-steal-your-soul, is to check if the application you are installing is restricted:
ls -lO /System/Library/Frameworks/Python.framework/Versions/2.7/ csrutil status
If it is restricted it cannot be removed (even with root) as long as SIP is enabled.
What to do?
So you have several different options you must try:
Pre-Option 0 - I think you are doing it already: I am not sure how you are maintaining your virtual environments, so just confirm you are going through the process, like here.
Option 2 - dangerous, but will work: Check and Disable the SIP. Unless you work in an environment protected by a team of IT guys with years of security experience, I don't suggest it. This option WILL solve the issue, but you basically getting rid of one of the security layers... GL!
There is another option (not sure if you tried it though)
csrutil disable), reboot, go through the
codesignprocess, reboot, and undo the Option 1 (
csrutil enable). I have never tried it, but it doesn't mean you can't :))) Credit goes to this SO answer here