ios系统可以使用python吗_4. 在苹果系统上使用 Python

4.1.获取和安装 MacPython¶

Mac OS X 10.8 附带 Apple 预安装的 Python 2.7 。 如果你愿意,可以从 Python 网站( https://www.python.org )安装最新版本的 Python 3 。 Python 的当前“通用二进制”版本可以在 Mac 的新 Intel 和传统 PPC CPU 上本地运行。

你安装后得到的东西有:

A MacPython 3.6 folder in your Applications folder. In here

you find IDLE, the development environment that is a standard part of official

Python distributions; PythonLauncher, which handles double-clicking Python

scripts from the Finder; and the “Build Applet” tool, which allows you to

package Python scripts as standalone applications on your system.

框架 /Library/Frameworks/Python.framework ,包括 Python 可执行文件和库。安装程序将此位置添加到 shell 路径。 要卸载 MacPython ,你可以简单地移除这三个项目。 Python 可执行文件的符号链接放在 /usr/local/bin/ 中。

Apple 提供的 Python 版本分别安装在 /System/Library/Frameworks/Python.framework 和 /usr/bin/python 中。 你永远不应修改或删除这些内容,因为它们由 Apple 控制并由 Apple 或第三方软件使用。 请记住,如果你选择从 python.org 安装较新的 Python 版本,那么你的计算机上将安装两个不同但都有用的 Python ,因此你的路径和用法与你想要执行的操作一致非常重要。

IDLE 包含一个帮助菜单,允许你访问 Python 文档。 如果您是 Python 的新手,你应该开始阅读该文档中的教程介绍。

如果你熟悉其他 Unix 平台上的 Python ,那么你应该阅读有关从 Unix shell 运行 Python 脚本的部分。

4.1.1.如何运行 Python 脚本¶

在 Mac OS X 上开始使用 Python 的最佳方法是通过 IDLE 集成开发环境,参见 IDE 部分,并在 IDE 运行时使用“帮助”菜单。

If you want to run Python scripts from the Terminal window command line or from

the Finder you first need an editor to create your script. Mac OS X comes with a

number of standard Unix command line editors, vim and

emacs among them. If you want a more Mac-like editor,

BBEdit or TextWrangler from Bare Bones Software (see

http://www.barebones.com/products/bbedit/index.html) are good choices, as is

TextMate (see https://macromates.com/). Other editors include

Gvim (http://macvim.org) and Aquamacs

(http://aquamacs.org/).

要从终端窗口运行脚本,必须确保:file:/usr/local/bin 位于 shell 搜索路径中。

要从 Finder 运行你的脚本,你有两个选择:

把脚本拖拽到 PythonLauncher

选择 PythonLauncher 作为通过 finder Info 窗口打开脚本(或任何 .py 脚本)的默认应用程序,然后双击脚本。 PythonLauncher 有各种首选项来控制脚本的启动方式。 拖拽方式允许你为一次调用更改这些选项,或使用其“首选项”菜单全局更改内容。

4.1.2.运行有图形界面的脚本¶

对于旧版本的 Python ,你需要注意一个 Mac OS X 的怪异之处:与 Aqua 窗口管理器通信的程序(换而言之,任何具有图形界面的程序)需要以特殊方式运行。 使用 pythonw 而不是 python 来启动这样的脚本。

With Python 3.6, you can use either python or pythonw.

4.1.3.配置¶

OS X 上的 Python 遵循所有标准的 Unix 环境变量,例如 PYTHONPATH ,但是为 Finder 启动的程序设置这些变量是非标准的,因为 Finder 在启动时不读取你的 .profile 或 .cshrc 。你需要创建一个文件 ~/.MacOSX/environment.plist 。 有关详细信息,请参阅 Apple 的技术文档 QA1067 。

更多关于在 MacPython 中安装 Python 包的信息,参阅 安装额外的 Python 包 部分。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值