Build Python programming environment in OS X system

  Most OS X systems are installed by default Python. After determining the Python installed, you also need to install a text editor, and make sure it is configured correctly.

  1. Check the installation of Python

  Hold down the Command + Space, then enter the terminal and press Enter. Enter the command python, outputs indicates the version of Python, last >>> is a prompt, which means from here enter Python commands. After seeing the output, and if the return to the terminal to launch Python window, or press Ctrl + D performs exit ().

  2. Python code running in a terminal

  After the terminal performs the python command, the prompt appears >>> input code as follows:


  >>>print("Hello Python interpreter!")
  Hello Python interpreter!
  >>>

 

  Message printed directly to the current terminal window.

  3. Install a text editor

  Sublime Text is a simple text editor: easy to install the OS X; code syntax projecting different colors; embedded within a terminal session Sublime Text window run the code. Download Sublime Text installer, visit http://sublimetext.com/3 , click Download. After downloading the program, open it, and then Sublime Text icon and drop it into the Applications folder.

  4. Use arranged so Sublime Text Python 3

  Python was informed that the full path to the interpreter, execute the following command:


  $ type -a python3

  python3 is /usr/local/bin/python3


  Now, start Sublime Text, and select the menu Tools-> Build System-> New Build System, which will open a new profile. Delete the contents, and then enter the following:


  {

    "cmd":["/usr/local/bin/python3","-u","$file"],

  }


  The configuration file named Python3.sublime-build, and save it to the default directory - when you select Save Sublime Text menu to open the directory.

 

Guess you like

Origin www.cnblogs.com/bingw/p/10892130.html