Mac Library Frameworks Python.framework
Created on 2008-08-18 13:01 by khinsen, last changed 2013-02-27 12:27 by Andrew.Jaffe.This issue is now closed. The FrameWork module contains classes that together provide a framework for an interactive Macintosh application. The programmer builds an application by creating subclasses that override various methods of the bases classes, thereby implementing the functionality wanted. Well, I'd say there were at least a few reasons. Certainly it's hugely advantageous as a layer that protects the system from processes that do bad things with root access, but the amount of people I see on the internet asking for help with what's analogous to surgery on a computer, who seem to know very little about the computer they're operating on, tells me that SIP will, without a doubt. Oct 23, 2019 The main bit of a framework install is the framework itself, installed in /Library/Frameworks/Python.framework. This can contain multiple versions of Python, if you want to remove just one version you have to remove the version-specific subdirectory: /Library/Frameworks/Python.framework/Versions/X.Y. There are two ways for installing Python on OS X/Mac, and they would affect how to uninstall python. (1) “.pkg” from Python.org (2) Installed through Homebrew But sometimes we just got the wrong versions or we just want to remove the.pkg version of Python from your Mac! Therefor, I wrote the solution down! Jan 15, 2019 Manually installing new versions is a pain and often forgotten. With the manual plan, before you know it, you’re on Python 2.7.10 (currently the Mac default) and the rest of the world has moved on.
- Mac Library Frameworks Python.framework School
- Python Gui Framework
- Python Framework Django
- Mac /system/library/frameworks/python.framework/versions/2.7
- Python Framework Web
Once your framework is ready to go, you need to decide where to install it. Where you install a framework also helps determine how to install the framework.
Locations for Public Frameworks
Third-party frameworks can go in a number of different file-system locations, depending on certain factors.
Most public frameworks should be installed at the local level in
/Library/Frameworks
.If your framework should only be used by a single user, you can install it in the
~/Library/Frameworks
subdirectory of the current user; however, this option should be avoided if possible.If they are to be used across a local area network, they can be installed in
/Network/Library/Frameworks
; however, this option should be avoided if possible.
For nearly all cases, installing your frameworks in /Library/Frameworks
is the best choice. Frameworks in this location are discovered automatically by the compiler at compile time and the dynamic linker at runtime. Applications that link to frameworks in other directories, such as ~/Library/Frameworks
or /Network/Library/Frameworks
, must specify the exact path to the framework at build time so that the dynamic linker can find it. If the path changes (as it might for a user home directory), the dynamic linker may be unable to find the framework.
Another reason to avoid installing frameworks in ~/Library/Frameworks
or /Network/Library/Frameworks
is the potential performance penalties. Frameworks installed in network directories or in network-based user home directories can cause significant delays in compilation times. Loading the framework across the network can also slow down the launch of the target application.
Third-party frameworks should never be installed in the /System/Library/Frameworks
directory. Access to this directory is restricted and is reserved for Apple-provided frameworks only.
Mac Library Frameworks Python.framework School
When you build an application or other executable, the compiler looks for frameworks in/System/Library/Frameworks
as well as any other location specified to the compiler. The compiler writes path information for any required frameworks in the executable file itself, along with version information for each framework. When the application is run, the dynamic link editor tries to find a suitable version of each framework using the paths in the executable file. If it cannot find a suitable framework in the specified location (perhaps because it was moved or deleted), it looks for frameworks in the following locations, in this order:
The explicit path to the framework that was specified at link time.
The
/Library/Frameworks
directory.The
/System/Library/Frameworks
directory.
If the dynamic link editor cannot locate a required framework, it generates a link edit error, which terminates the application.
Locations for Private Frameworks
Custom frameworks intended for internal use should be installed inside the application that uses them. Frameworks embedded in an application are stored in the Frameworks
directory of the application bundle. The advantage of embedding frameworks in this manner is that it guarantees the application always has the correct version of the framework to run against. See Embedding a Private Framework in Your Application Bundle for information on how to embed a custom framework in your application.
The limitation of embedding frameworks is that you cannot share the framework among a suite of applications. If your company develops a suite of applications that rely on the same framework, you might want to install one copy of that framework that all of the applications can share. In such a situation, you should install the frameworks in the /Library/Frameworks
directory and make sure the frameworks bundle does not contain any public header information.
Installing Frameworks
How you install frameworks depends on your framework. If your framework is bundled inside of a particular application, there is nothing special you need to do. The user can drag the application bundle to a local system and use the application without any need for additional installation steps.
If your framework is external to an application, you should use an installation package to make sure it is put in the proper location. You should also use an installation package in situations where an older version of your framework might be in place. In that case, you might want to write some scripts to update an existing framework bundle rather than replace it entirely. For example, you may want to install a new major version of your framework without disturbing any other versions. Similarly, if you have multiple applications that rely on the same framework, your installation package should check for the existence of the framework and install it only as needed.
For more information on creating installation packages, see Distributing Apps Outside the Mac App Store.
Copyright © 2003, 2013 Apple Inc. All Rights Reserved. Terms of Use Privacy Policy Updated: 2013-09-17
Bob Savage <bobsavage@mac.com>
Python on a Macintosh running Mac OS X is in principle very similar to Python onany other Unix platform, but there are a number of additional features such asthe IDE and the Package Manager that are worth pointing out.
4.1. Getting and Installing MacPython¶
Mac OS X 10.8 comes with Python 2.7 pre-installed by Apple. If you wish, youare invited to install the most recent version of Python 3 from the Pythonwebsite (https://www.python.org). A current “universal binary” build of Python,which runs natively on the Mac’s new Intel and legacy PPC CPU’s, is availablethere.
What you get after installing is a number of things:
A
Python3.8
folder in yourApplications
folder. In hereyou find IDLE, the development environment that is a standard part of officialPython distributions; PythonLauncher, which handles double-clicking Pythonscripts from the Finder; and the “Build Applet” tool, which allows you topackage Python scripts as standalone applications on your system.A framework
/Library/Frameworks/Python.framework
, which includes thePython executable and libraries. The installer adds this location to your shellpath. To uninstall MacPython, you can simply remove these three things. Asymlink to the Python executable is placed in /usr/local/bin/.
The Apple-provided build of Python is installed in/System/Library/Frameworks/Python.framework
and /usr/bin/python
,respectively. You should never modify or delete these, as they areApple-controlled and are used by Apple- or third-party software. Remember thatif you choose to install a newer Python version from python.org, you will havetwo different but functional Python installations on your computer, so it willbe important that your paths and usages are consistent with what you want to do.
IDLE includes a help menu that allows you to access Python documentation. If youare completely new to Python you should start reading the tutorial introductionin that document.
If you are familiar with Python on other Unix platforms you should read thesection on running Python scripts from the Unix shell.
4.1.1. How to run a Python script¶
Your best way to get started with Python on Mac OS X is through the IDLEintegrated development environment, see section The IDE and use the Help menuwhen the IDE is running.
If you want to run Python scripts from the Terminal window command line or fromthe Finder you first need an editor to create your script. Mac OS X comes with anumber of standard Unix command line editors, vim andemacs among them. If you want a more Mac-like editor,BBEdit or TextWrangler from Bare Bones Software (seehttp://www.barebones.com/products/bbedit/index.html) are good choices, as isTextMate (see https://macromates.com/). Other editors includeGvim (http://macvim-dev.github.io/macvim/) and Aquamacs(http://aquamacs.org/).
To run your script from the Terminal window you must make sure that/usr/local/bin
is in your shell search path.
To run your script from the Finder you have two options:
Drag it to PythonLauncher
Select PythonLauncher as the default application to open yourscript (or any .py script) through the finder Info window and double-click it.PythonLauncher has various preferences to control how your script islaunched. Option-dragging allows you to change these for one invocation, or useits Preferences menu to change things globally.
4.1.2. Running scripts with a GUI¶
With older versions of Python, there is one Mac OS X quirk that you need to beaware of: programs that talk to the Aqua window manager (in other words,anything that has a GUI) need to be run in a special way. Use pythonwinstead of python to start such scripts.
With Python 3.8, you can use either python or pythonw.
4.1.3. Configuration¶
Python on OS X honors all standard Unix environment variables such asPYTHONPATH
, but setting these variables for programs started from theFinder is non-standard as the Finder does not read your .profile
or.cshrc
at startup. You need to create a file~/.MacOSX/environment.plist
. See Apple’s Technical Document QA1067 fordetails.
For more information on installation Python packages in MacPython, see sectionInstalling Additional Python Packages.
4.2. The IDE¶
MacPython ships with the standard IDLE development environment. A goodintroduction to using IDLE can be found athttp://www.hashcollision.org/hkn/python/idle_intro/index.html.
4.3. Installing Additional Python Packages¶
There are several methods to install additional Python packages:
Packages can be installed via the standard Python distutils mode (
pythonsetup.pyinstall
).Many packages can also be installed via the setuptools extensionor pip wrapper, see https://pip.pypa.io/.
4.4. GUI Programming on the Mac¶
Python Gui Framework
There are several options for building GUI applications on the Mac with Python.
Follow these steps to use the Photos library repair tool:. How to repair a photo library on mac. Hold down the Option and Command keys while you open Photos on your Mac.
PyObjC is a Python binding to Apple’s Objective-C/Cocoa framework, which isthe foundation of most modern Mac development. Information on PyObjC isavailable from https://pypi.org/project/pyobjc/.
The standard Python GUI toolkit is tkinter
, based on the cross-platformTk toolkit (https://www.tcl.tk). An Aqua-native version of Tk is bundled with OSX by Apple, and the latest version can be downloaded and installed fromhttps://www.activestate.com; it can also be built from source.
wxPython is another popular cross-platform GUI toolkit that runs natively onMac OS X. Packages and documentation are available from https://www.wxpython.org.
PyQt is another popular cross-platform GUI toolkit that runs natively on MacOS X. More information can be found athttps://riverbankcomputing.com/software/pyqt/intro.
4.5. Distributing Python Applications on the Mac¶
The “Build Applet” tool that is placed in the MacPython 3.6 folder is fine forpackaging small Python scripts on your own machine to run as a standard Macapplication. This tool, however, is not robust enough to distribute Pythonapplications to other users.
Python Framework Django
The standard tool for deploying standalone Python applications on the Mac ispy2app. More information on installing and using py2app can be foundat http://undefined.org/python/#py2app.
Mac /system/library/frameworks/python.framework/versions/2.7
4.6. Other Resources¶
The MacPython mailing list is an excellent support resource for Python users anddevelopers on the Mac:
Python Framework Web
Another useful resource is the MacPython wiki: