May 10, 2021 Python2
In this section, we'll show you how to build a Python development environment locally.
Python can be applied to multiple platforms including Linux and Mac OS X, which are already self-afraid, Python-supported, and do not require reconfiguration and installation.
Download the latest version of Python 2.7.9 directly under Windows, and choose when installing
You can enter the "python" command through the terminal window to see if the local installation version of Python and Python is already installed.
Python's latest source codes, binary documents, news, and more can be found on Python's website:
Python Website: http://www.python.org/
You can download Python's documents in the links below, and you can download documents in formats such as HTML, PDF, and PostScript.
Python document download address: www.python.org/doc/
Python has been ported on many platforms (modified to make it work on different platforms).
You need to download the binary code for the platform you use, and then install Python.
If the binary code for your platform is not available, you need to compile the source code manually using the C compiler.
The compiled source code is more selective in functionality, providing more flexibility for Python installations.
Here's how to install Python on different platforms:
Here are some simple steps to install Python on the Unix and Linux platforms:
After doing so, Python is installed in the /usr/local/bin directory, and the Python library is installed in /usr/local/lib/pythonXX, the version number of Python used by XX for you.
Here are some simple steps to install Python on the Window platform:
Recent Mac systems come with their own Python environments, but come with an older version of Python, and you can view the new features of Python on your MAC at link http://www.python.org/download/mac/.
The full Python installation tutorial on macs you can view:
http://www.cwi.nl/~jack/macpython.htmlPrograms and executables can be in many directories, and these paths are likely not in the search path where the operating system provides executable files.
Path is stored in an environment variable, a named string maintained by the operating system. These variables contain information about the available command-line interpreters and other programs.
The path variable in Unix or Windows is PATH (UNIX case sensitive, Windows case insensescies).
In Mac OS, Python's installation path was changed during the installer process. If you need to reference Python in another directory, you must add python directories to the path.
setenv PATH "$PATH:/usr/local/bin/python", press Enter.
export PATH="$PATH:/usr/local/bin/python", press Enter.
PATH="$PATH:/usr/local/bin/python", press Enter.
Note: /usr/local/bin/python is Python's installation directory.
Add a Python directory to the environment variable:
path=%path%;C:\Python
Press Enter.
Note: C: .Python is Python's installation directory.
You can also set it up by:
Here are a few important environment variables that apply to Python:
The name of the variable | Describe |
---|---|
PYTHONPATH | PYTHONPATH is the Python search path, and by default our import modules are looking for it from PYTHONPATH. |
PYTHONSTARTUP | After Python starts, look for the PYTHONSTARTUP environment variable and execute the execution code specified by the variable in this file. |
PYTHONCASEOK | Adding an environment variable to PYTHONCASEOK will make Python case insensive when importing modules. |
PYTHONHOME | Another module searches for paths. It is typically embedded in the PYTHONSTARTUP or PYTHONPATH directory, making it easier to switch between the two module libraries. |
There are three ways to run Python:
You can go to Python through the command line window and start writing Python code in the interactive interpreter.
You can code Python on Unix, DOS, or any other system that provides a command line or shell.
Here are the Python command line parameters:
Options | Describe |
---|---|
-d | Debug information is displayed at parsing |
-O | Build optimization code ( .pyo file ) |
-S | The location to find the Python path is not introduced at startup |
-v | Output Python version number |
-X | Built-based exceptions (for strings only) have become obsolete since version 1.6. |
-c cmd | Execute the Python script and use the run results as a cmd string. |
file | The Python script is executed in a given Python file. |
By introducing an interpreter in your application, you can execute Python scripts on the command line, as follows:
Note: When executing a script, check that the script has executable permissions.
You can use a graphical user interface (GUI) environment to write and run Python code. The following is recommended for IDEs used on each platform:
Before you move on to the next chapter, make sure that your environment is successfully built. If you are not able to establish the right environment then you can get help from your system administrator.
The examples given in a later section have been tested in Python 2.4.3 under Centos (Linux).
Python 是跨平台的,它可以运行在 Windows、Mac 和各种 Linux/Unix 系统上。在 Windows 上写 Python 程序,放到 Linux 上也是能够运行的。
要开始学习 Python 编程,首先就得把 Python 安装到你的电脑里。安装后,你会得到 Python 解释器(就是负责运行 Python 程序的),一个命令行交互环境,还有一个简单的集成开发环境。
You can
also use Coding Cloud Studio,
an online cloud development tool. I
t provides a native online Linux command interaction terminal environment, Python run interpreter, online development text editor, you can create Python files directly in your workstation and run your Written Python program in Cloud Studio. Y
ou can then skip the rest of this section, such as the installation Python operating environment and the integrated development environment.
If you're having trouble, you can view the Coding help documentation!