Python Environment setup

Source: Internet
Author: User
Tags python script

Python download

Python's latest source code, binary documents, news, etc. can be found on the Python website:

Python official website: http://www.python.org/

You can download Python documents in the following links, and you can download documents in HTML, PDF and PostScript formats.

Python Document: www.python.org/doc/

Windows platform installs Python:

Here are the simple steps to install Python on the Window platform:

    • Open a Web browser to access http://www.python.org/download/
    • Select the Window platform installation package in the download list, in the package format:python-xyz.msi file, XYZ is the version number you want to install.
    • To use setup python-xyz.msi, Windows systems must be supported with Microsoft Installer 2.0. Just save the installation file to your local computer, and then run it to see if your machine supports MSI. Windows XP and later versions already have MSI, and many older machines can also install MSI.
    • After downloading, double-click the download package, go to the Python Installation Wizard, the installation is very simple, you just need to use the default settings always click "Next" until the installation is complete.

Environment variable Configuration

Programs and executables can be in many directories, and these paths are probably not in the search path where the operating system provides executable files.

The path is stored in an environment variable, which is a named string maintained by the operating system. These variables contain information about the available command-line interpreters and other programs.

Path variable in UNIX or Windows is path (Unix case-sensitive, Windows is case-insensitive).

In Mac OS, the setup process changes the Python installation path. If you need to reference Python in another directory, you must add a Python directory to the path.

Setting environment variables in Windows

To add a Python directory to an environment variable:

in the Command Prompt box (cmd): Enter

Path=%path%;  C:      

Press "Enter".

Note: C:\Python is the installation directory for Python.

You can also set it in the following ways:

    • Right-click on "Computer" and click "Properties"
    • Then click "Advanced System Settings"
    • Select "Path" under the "System Variables" window and double click!
    • Then in the "path" line, add the Python installation path (my D:\Python32), so later, add the path. PS: Remember, the path is separated directly by a semicolon ";"
    • After the final setting is successful, on the cmd command line, enter the command "Python" and you can have the relevant display.

Python Environment variables

Here are a few important environment variables that apply to Python:

Variable name Description
PYTHONPATH Pythonpath is the Python search path, and by default our import module will be searched from the 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 Pythoncaseok environment variables makes python case-insensitive when importing modules.
Pythonhome

Another module search path. It is typically embedded in the Pythonstartup or Pythonpath directory, making it easier to switch between two module libraries.

Run Python

There are three ways to run Python:

1. Interactive interpreter:

You can enter Python from a command-line window and start writing Python code in the interactive interpreter.

You can do python coding in unix,dos or any other system that provides a command line or shell.

$ python # Unix/linux

Or

C:>python # Windows/dos

The following are the Python command-line parameters:

Options Description
-D Display debug information at parse time
-O Generate optimization code (. pyo file)
-S Do not introduce a location to find Python paths at startup
-V Output Python version number
-X The built-in exception (for strings only) since the 1.6 release is obsolete.
-C cmd Executes the Python script and runs the result as a CMD string.
File Executes a Python script in the given Python file.
2. Command line script

In your application, you can execute a python script on the command line by introducing an interpreter, as follows:

$ python script.py # Unix/linux

Or

C:>python script.py # Windows/dos

Note: when executing a script, check to see if the script has executable permissions.

3. Integrated development Environment (ide:integrated development environment): Pycharm

Pycharm is a Python IDE built by JetBrains that supports MacOS, Windows, Linux systems.

Pycharm Features: Debug, Syntax highlighting, project management, code jump, smart tips, AutoComplete, Unit testing, versioning ...

pycharm:https://www.jetbrains.com/pycharm/download/

Python Environment setup

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.