官术网_书友最值得收藏!

Python on macOS

macOS X, High Sierra has a preloaded version of Python 2.7 out-of-the-box. If you have macOS X, you will not have to install or configure anything else in order to use Python 2. If you want to use Python3, then follow these instructions.

Before you install Python, you’ll be required to install GCC:

  • GCC can be obtained by downloading XCode (https://developer.apple.com/xcode/).
  • The smaller command-line tools, or the even smaller OSX-GCC-Installer package, can be downloaded.
If you have already installed XCode, do not install OSX-GCC-Installer. In combination, the software can cause issues that are difficult to diagnose. If you perform a fresh install of XCode, you will also need to add the command-line tools, by running xcode-select --install on the Terminal.

While macOS X comes with a large number of UNIX utilities, those familiar with Linux systems will notice one key component missing: a package manager. Homebrew fills this void. To install Homebrew, open a Terminal and run the following command:

$ ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

Once Homebrew is installed, insert the Homebrew directory at the top of your PATH environment variable. You can do this by adding the following line to the bottom of your ~/.profile file. It is important to note that various shells have their own bash profile files. Make sure that you choose the correct one:

export PATH=/usr/local/bin:/usr/local/sbin:$PATH

Now, we can install Python 3, as follows:

$ brew install python
$ python3

We will also launch the Homebrew-installed Python 3 interpreter. To check the Python version, we can run the following commands:

$ python --version
Python 3.6.4 # Success!
主站蜘蛛池模板: 沁水县| 宜宾县| 揭阳市| 松滋市| 石嘴山市| 高唐县| 高雄县| 闽清县| 和田市| 施甸县| 靖远县| 无棣县| 永城市| 平昌县| 米泉市| 昌图县| 新龙县| 汕尾市| 汕尾市| 浮梁县| 永吉县| 汉沽区| 孟连| 额济纳旗| 偏关县| 梅州市| 崇仁县| 武义县| 嘉义县| 资阳市| 锡林郭勒盟| 新郑市| 湟中县| 沭阳县| 龙里县| 靖西县| 莲花县| 德保县| 吉木乃县| 长沙市| 进贤县|