MAC Platform Installation Python:

You can also install it by referring to the way the source is installed.

Environment Variable Configuration

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

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.

The path variable in Unix or Windows is PATH (UNIX is case sensitive and Windows is not case sensitive).

In Mac OS, the installation path of python was changed during the installation process. If you need to reference Python in other directories, you must add the Python directory to the path.

Set environment variables on Unix/Linux

Python environment variable

The following important environment variables apply to Python:

Variable Name

Description

PYTHONPATH

PYTHONPATH is the Python search path. By default, the modules we import will be searched from PYTHONPATH.

PYTHONSTARTUP

After Python starts, look for the PYTHONSTARTUP environment variable and then execute the code in the file specified by this variable.

Another module search path. It is usually embedded in the PYTHONSTARTUP or PYTHONPATH directory, making it easier to switch between the two module libraries.

Run Python

There are three ways to run Python:

1, interactive interpreter:

You can go to python through the command line window and start writing Python code in the interactive interpreter.

You can do python encoding on Unix, DOS or any other system that provides a command line or shell.

$ python # Unix/Linux

Or

C:>python # Windows/DOS

The following are Python command line arguments:

Options

Description

-d

Show debug information when parsing

-O

Generate optimized code ( .pyo file )

-S

Do not introduce a location to find the Python path at startup

-V

Output Python version number

-X

Built-in exceptions (only for strings) since version 1.6 are obsolete.

-c cmd

Execute the Python script and run the result as a cmd string.

file

Execute a python script in a given python file.

Run Python3 program in Cloud Studio

The 3.0 version of Python, often referred to as Python3000, or Py3k for short. This is a larger upgrade than the previous version of Python. In order not to introduce too much cumbersome, Python 3.0 was not designed to be backward compatible. Many programs designed for earlier versions of Python are not working properly on Python 3.0. The Python development environment that Cloud Studio provides for us is the Python version 2.7. The following steps will allow you to run a program written in Python3 on Cloud Studio

step1: Sign in to Tencent Cloud Developer Platform, select PHP + Python + Java development environment, at this time, I see the terminal input command python --version can see that the currently used python interpreter version is 2.7.12

step2: Install Python3, execute the command, install Python3 and see if the interpreter works.