question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Howto run with a framework version of python

See original GitHub issue

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

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

12reactions
cameronmaskecommented, Mar 5, 2018

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

8reactions
aleksijohanssoncommented, 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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

how to run a Framework build of python (and can that ... - GitHub
$ python example_progress_bar_1.py This program needs access to the screen. Please run with a Framework build of python, and only when you are ......
Read more >
How to ensure I use the correct python version when I have ...
Manually change the default version · Setup aliases to the different versions: tmp$ type python3.7 python3.7 is aliased to `/usr/local/opt/python ...
Read more >
5. Using Python on a Mac — Python 3.11.1 documentation
Running scripts with a GUI¶. With older versions of Python, there is one macOS quirk that you need to be aware of: programs...
Read more >
Web development with Python on Windows | Microsoft Learn
A step-by-step guide to get started using Python for web development on Windows, including set up for frameworks like Flask and Django.
Read more >
How to install Django
This document will get you up and running with Django. Install Python¶. Django is a Python web framework. See What Python version can...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found