Home  >  Article  >  Backend Development  >  Set up Python compilation environment in Windows environment

Set up Python compilation environment in Windows environment

零到壹度
零到壹度Original
2018-04-16 11:26:413356browse

The content of this article is to build a Python compilation environment in the Windows environment. It has certain reference value. Now I share it with you. Friends in need can refer to it

Windows Not all systems have Python installed by default, so you may need to download and install it, and then download and install a
text editor (using the previous PyCham: click to open the link).
1. Install Python
First, check whether Python is installed on your system. To do this, type command in the Start menu and press Enter to open a command window; you can also hold down the Shift key and right-click on the desktop and select "Open command window here." Enter python in the terminal window
and press Enter; if the Python prompt (>>>) appears, it means that Python is installed on your system. However,
you may also see an error message stating that python is an unrecognized command.
If this is the case, you will need to download the Windows Python installer. To do this, visit http://python.org/downloads/.
You will see two buttons for downloading Python 3 and Python 2. Click the button to download Python 3, which will automatically download the correct installer for your system. After downloading the installer, run it. Be sure to select the checkbox Add Python to


PATH (shown in Figure 1-2), which makes it easier to configure your system.


2. Start a Python terminal session

Simplify text editor configuration by configuring the system to run Python in a terminal session. Open a

command window and execute the command python in it. If the Python prompt (>>>) appears, it means that Windows has found the Python version you just installed.

C:\>  python
Python 3.5.0 (v3.5.0:374f501f4567, Sep 13 2015, 22:15:05) [MSC v.1900 32 bit
(Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>>

If so, you can skip directly to the next section - "Running Python in a Terminal Session".
However, the output may look like this:

C:\>  python
'python' is not recognized as an internal or external command, operable
program or batch file.

In this case, you will have to tell Windows how to find the version of Python you just installed. The command python is usually
stored in the C drive, so please open the C drive in Windows Explorer, find and open the folder starting with Python, and

then find the file python. For example, in my computer, there is a folder called Python35, which has a file called python

, so the path of the file python is C:\Python35\python. If you can't find this file, enter python in the Windows Resource Manager's search box. This will allow you to know exactly where the command python is stored on your system.
If you think you know the path to the command python, enter the path in the terminal window to test. To do this, open a


command window and enter the full path you determined:

C:\>  C:\Python35\python
Python 3.5.0 (v3.5.0:374f501f4567, Sep 13 2015, 22:15:05) [MSC v.1900 32 bit
(Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>>

If this works, you already know how to access Python.

3. Run Python in a terminal session

Execute the following command in the Python session and confirm that you see the output "Hello Python world!".

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

Whenever you want to run a Python code snippet, open a command window and start a Python terminal session. To close the terminal session, press Ctrl Z and then press the Enter key, or execute the command exit().



Related recommendations:


Building a Python programming environment in Windows systems

Building Python environment under windows system

Building python nltk development environment under windows environment

The above is the detailed content of Set up Python compilation environment in Windows environment. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn