<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ??一站式輕松地調用各大LLM模型接口,支持GPT4、智譜、豆包、星火、月之暗面及文生圖、文生視頻 廣告
                ### 導航 - [索引](../genindex.xhtml "總目錄") - [模塊](../py-modindex.xhtml "Python 模塊索引") | - [下一頁](../reference/index.xhtml "Python 語言參考") | - [上一頁](windows.xhtml "3. 在Windows上使用 Python") | - ![](https://box.kancloud.cn/a721fc7ec672275e257bbbfde49a4d4e_16x16.png) - [Python](https://www.python.org/) ? - zh\_CN 3.7.3 [文檔](../index.xhtml) ? - [安裝和使用 Python](index.xhtml) ? - $('.inline-search').show(0); | # 4. 在蘋果系統上使用 Python 作者Bob Savage <[bobsavage@mac.com](mailto:bobsavage%40mac.com)> 運行 Mac OS X 的 Macintosh上 的 Python 原則上與任何其他 Unix 平臺上的 Python 非常相似,但是還有一些額外的功能,例如 IDE 和包管理器,值得一提。 ## 4.1. 獲取和安裝 MacPython Mac OS X 10.8 附帶 Apple 預安裝的 Python 2.7 。 如果你愿意,可以從 Python 網站( <https://www.python.org> )安裝最新版本的 Python 3 。 Python 的當前“通用二進制”版本可以在 Mac 的新 Intel 和傳統 PPC CPU 上本地運行。 你安裝后得到的東西有: - 一個 `MacPython 3.6` 文件夾在你的 `Applications` 文件夾中。 在這里你可以找到 IDLE ,這是開發環境,是官方 Python 發行版的標準部分; PythonLauncher ,它處理從 Finder 雙擊運行的 Python 腳本; 以及“ Build Applet ”工具,它允許你將 Python 腳本打包為系統上的獨立應用程序。 - 框架 `/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) 部分,并在 IDE 運行時使用“幫助”菜單。 如果要從終端窗口命令行或 Finder 運行 Python 腳本,首先需要一個編輯器來創建腳本。 Mac OS X 附帶了許多標準的 Unix 命令行編輯器,如 **vim** 和 **emacs** 。 如果你想要一個更 Mac 化的編輯器,那么:program:BBEdit 或來自 Bare Bones Software 的 **TextWrangler** (參見 <http://www.barebones.com/products/bbedit/index.html> )是不錯的選擇 ,就如 **TextMate`(參見 https://macromates.com/ )。 其他編輯器包括 :program:`Gvim** ( <http://macvim-dev.github.io/macvim/> )和 **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** 來啟動這樣的腳本。 Python 3.6 中, 你可使用 **python** 或 **pythonw** 。 ### 4.1.3. 配置 OS X 上的 Python 遵循所有標準的 Unix 環境變量,例如 [`PYTHONPATH`](cmdline.xhtml#envvar-PYTHONPATH) ,但是為 Finder 啟動的程序設置這些變量是非標準的,因為 Finder 在啟動時不讀取你的 `.profile` 或 `.cshrc` 。你需要創建一個文件 `~/.MacOSX/environment.plist` 。 有關詳細信息,請參閱 Apple 的技術文檔 QA1067 。 更多關于在 MacPython 中安裝 Python 包的信息,參閱 [安裝額外的 Python 包](#mac-package-manager) 部分。 ## 4.2. IDE MacPython 附帶標準的 IDLE 開發環境。 有關使用 IDLE 的詳細介紹,請訪問 [http://www.hashcollision.org/hkn/python/idle\_intro/index.html](http://www.hashcollision.org/hkn/python/idle_intro/index.html) 。 ## 4.3. 安裝額外的 Python 包 有幾個方法可以安裝額外的 Python 包: - 可以通過標準的 Python distutils 模式( `python setup.py install` )安裝軟件包。 - 許多包也可以通過 **setuptools** 擴展或 **pip** 包裝器安裝,請參閱 <https://pip.pypa.io/> 。 ## 4.4. Mac 上的圖形界面編程 使用 Python 在 Mac 上構建 GUI 應用程序有多種選擇。 *PyObjC* 是一個 Python 到 Apple 的 Objective-C/Cocoa 框架的綁定,這是大多數現代 Mac 開發的基礎。 有關 PyObjC的 信息,請訪問 <https://pythonhosted.org/pyobjc/> 。 標準的 Python GUI 工具包是 [`tkinter`](../library/tkinter.xhtml#module-tkinter "tkinter: Interface to Tcl/Tk for graphical user interfaces") ,基于跨平臺的 Tk 工具包( <https://www.tcl.tk> )。 Apple 的 OS X 捆綁了 Aqua 原生版本的 Tk ,最新版本可以從 <https://www.activestate.com> 下載和安裝;它也可以從源代碼構建。 *wxPython* 是另一種流行的跨平臺 GUI 工具包,可在 Mac OS X 上本機運行。軟件包和文檔可從 <https://www.wxpython.org> 獲得。 *PyQt* 是另一種流行的跨平臺 GUI 工具包,可在 Mac OS X 上本機運行。更多信息可在 <https://riverbankcomputing.com/software/pyqt/intro> 上找到。 ## 4.5. 在 Mac 上分發 Python 應用程序 放置在 MacPython 3.6 文件夾中的“ Build Applet ”工具適用于在你自己的計算機上打包小型 Python 腳本以作為標準 Mac 應用程序運行。 但是,此工具不夠強大,無法將 Python 應用程序分發給其他用戶。 在 Mac 上部署獨立 Python 應用程序的標準工具是 **py2app** 。有關安裝和使用 py2app 的更多信息,請訪問 <http://undefined.org/python/#py2app> 。 ## 4.6. 其他資源 MacPython 郵件列表是 Mac 上 Python 用戶和開發人員的優秀支持資源: <https://www.python.org/community/sigs/current/pythonmac-sig/> 另一個有用的資源是 MacPython wiki : <https://wiki.python.org/moin/MacPython> ### 導航 - [索引](../genindex.xhtml "總目錄") - [模塊](../py-modindex.xhtml "Python 模塊索引") | - [下一頁](../reference/index.xhtml "Python 語言參考") | - [上一頁](windows.xhtml "3. 在Windows上使用 Python") | - ![](https://box.kancloud.cn/a721fc7ec672275e257bbbfde49a4d4e_16x16.png) - [Python](https://www.python.org/) ? - zh\_CN 3.7.3 [文檔](../index.xhtml) ? - [安裝和使用 Python](index.xhtml) ? - $('.inline-search').show(0); | ? [版權所有](../copyright.xhtml) 2001-2019, Python Software Foundation. Python 軟件基金會是一個非盈利組織。 [請捐助。](https://www.python.org/psf/donations/) 最后更新于 5月 21, 2019. [發現了問題](../bugs.xhtml)? 使用[Sphinx](http://sphinx.pocoo.org/)1.8.4 創建。
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看