Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Howto run with a framework version of python #1416

Closed
svandragt opened this issue Feb 11, 2018 · 5 comments
Closed

Howto run with a framework version of python #1416

svandragt opened this issue Feb 11, 2018 · 5 comments

Comments

@svandragt
Copy link

svandragt commented Feb 11, 2018

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.

Describe your environment
  1. macOs High Sierra 10.13.3
  2. Python version: 3.6.4
  3. Pipenv version: pipenv, version 9.0.3
Expected result

Expect the virtual environment to use the installed framework version of python.

Actual result

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.

Steps to replicate
  • install python.org 3.6.4 with the default installation options, reinstall pip3; and pipenv, pew and virtualenv with --user.
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
@uranusjr
Copy link
Member

uranusjr commented Feb 11, 2018

This is a bug in virtualenv.

@cameronmaske
Copy link

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

@aleksijohansson
Copy link

aleksijohansson commented Apr 11, 2018

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.

@danielsiwiec
Copy link

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 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

@mtianyan
Copy link

Wish SO much this was the default Too. This Also took me way too much time to find.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants