I'm starting a wxPython project which requires a framework build of Python. I installed 3.6.4 from Python.org including all the options, and have pipenv use it with the pipenv --python 3.6.4
arguments (followed by a pipenv install wxpython
).
Pipenv tells us it's using a framework build of python (path contains Python.framework):
Using /Library/Frameworks/Python.framework/Versions/3.6/bin/python3.6m to create virtualenv…
However the program won't run, it says it's not using a framework build of python.
Expect the virtual environment to use the installed framework version of python.
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.
mkdir wxpythontest && cd wxpythontest
pipenv --python 3.6.4
pipenv install wxpython
curl https://gist.githubusercontent.com/svandragt/d1f0d6e2b3d19053b940fffecb3de88e/raw/4b4f9cb881f5dab6f97b96d3ca0ef4347a0a218e/hello.py -O hello.py
pipenv run python hello.py
This is a bug in virtualenv.
Hey all,
Don't want to re-open this issue, but it comes up as a prominent result when googling this error.
I'm just popping my solution here so hopefully, it will save others sometime!
I've just adapt the script found on wxPython to work nicely with pipenv.
I create a wrappedpython.sh
script with the following...
#!/bin/bash
# What real Python executable to use
PYVER=3.6
PYTHON=/Library/Frameworks/Python.framework/Versions/$PYVER/bin/python$PYVER
export PYTHONHOME=$(pipenv --venv)
exec $PYTHON $1
Then after chmod +x python.sh
it, I run use it as a drop in replacement for pipenv run python
, e.g. ./python.sh app.py
Here is another python.sh
helper for running a framework version (install with PYTHON_CONFIGURE_OPTS="--enable-framework" pyenv install x.x.x
as instructed in matplotlib documentation) of python installed with pyenv:
#!/usr/bin/env bash
# Use pyenv provided framework version of python instead of pipenv (virtualenv) copy.
PYTHON=$(pyenv which python)
export PYTHONHOME=$(pipenv --venv)
exec $PYTHON $1
Works as the script in the above comment.
Wish SO much this was the default. This took me way too much time to find.
Hey all,
Don't want to re-open this issue, but it comes up as a prominent result when googling this error.
I'm just popping my solution here so hopefully, it will save others sometime!
I've just adapt the script found on wxPython to work nicely with pipenv.I create a wrapped
python.sh
script with the following...#!/bin/bash # What real Python executable to use PYVER=3.6 PYTHON=/Library/Frameworks/Python.framework/Versions/$PYVER/bin/python$PYVER export PYTHONHOME=$(pipenv --venv) exec $PYTHON $1
Then after
chmod +x python.sh
it, I run use it as a drop in replacement forpipenv run python
, e.g../python.sh app.py
Wish SO much this was the default Too. This Also took me way too much time to find.
Most helpful comment
Hey all,
Don't want to re-open this issue, but it comes up as a prominent result when googling this error.
I'm just popping my solution here so hopefully, it will save others sometime!
I've just adapt the script found on wxPython to work nicely with pipenv.
I create a wrapped
python.sh
script with the following...Then after
chmod +x python.sh
it, I run use it as a drop in replacement forpipenv run python
, e.g../python.sh app.py