程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
您现在的位置: 程式師世界 >> 編程語言 >  >> 更多編程語言 >> Python

Python installation tutorial (novice)

編輯:Python

First contact Python, It may be reptiles or information AI Children of development , All say Python The language is simple , It's always good to learn so much , Here's a completely unknown Python Small white to install Python Wait for a series of work records , And the problems encountered will also be written , Let Xiaobai who doesn't understand it at all start to install , And finish the first Hello world Code .

[Python install ]

at present ,Python There are two versions , One is 2.x edition , One is 3.x edition , The two versions are not compatible . because 3.x The version is becoming more and more popular , Our tutorial will be based on the latest Python 3.9 Version based .

  1. Get into Python Official download page of
    http://www.python.org/download/

    There are many versions , We choose the latest version 3.9.0

    After downloading, click Run , The installation interface will appear , Remember to tick on

    When this occurs, the installation is successful

  2. function Python
    After successful installation , Open the command prompt window (win+R, In the input cmd enter ), Knock in python after , Two things happen :

    Situation 1 :

    The appearance of this indicates python Installation successful . You see the prompt >>> It means that we are already in Python In an interactive environment , You can type anything Python Code , After returning, you will get the execution result immediately . Now? , Input exit() And return , You can quit Python Interactive environment ( Or close the command line window directly ).

    Situation two : Get a mistake :

    I won't demonstrate it here , Because I installed it successfully , Let me show you , Use the wrong pythonn Instead of python To use , This will prompt the error message .

    1. Configure environment variables
      This is because Windows According to one Path The path set by the environment variable to find python.exe, If not , You're going to report a mistake . If the tick is omitted during installation Add Python 3.9 to PATH, Then we need to manually handle python.exe The path where is added to Path in .
      If it is found that you forget to check or will not set PATH Path so , If you reinstall it, remember to check Add Python 3.9 to PATH Just ok 了 .( The first 2 Step : Error messages are generally caused by not configuring environment variables )

    2. step : Right click on my computer –> Select Properties –> Select advanced system settings –> Select the environment variable in the lower right corner

Environment variables mainly include user variables and system variables , The environment variables that need to be set are in these two variables
The user variable is that the downloaded program can be downloaded in cmd Use in command , Write the absolute path of the program to the user variable to use



5. Test output
win+R , Input cmd enter

Input python enter , Get into python development environment
.
It should be noted that the calling function ( Print etc. ) Need brackets , Otherwise it will prompt

Directly in print If you add a paragraph of text to output , You need to put double or single quotation marks on the text . We found ,print In addition to the printed text , It can also output all kinds of numbers 、 Calculation results 、 Comparison results, etc . You try to be yourself print Something else , See what works , Which will fail , If you are interested, guess the reason of failure again .
.
Actually in python At the command line ,print It can be omitted , By default, the result of each command will be output . Just like this. :

[ Install development tools ]

install PyCharm Tools , It can be downloaded from the Internet , A lot of resources , There are also installation free versions , Decompression can be used , What I am demonstrating now is what needs to be installed Pycharm development tool .

.

.
.

.

.
The first time pycharm It will show this






If you choose this way, there will be one venv Folder , When creating a new project, a virtual environment is created by default


Unwanted venv Virtual environment folder , Choose the second option and set python Environment , The default is none

Click next to complete the creation of the empty project

Create a folder for category management

Create a python It can be written in the document python sentence


Let's run it python Code , Print the first sentence python Code ,Hello World Ha ha ha !!!

pyCharm Plug in for

Download of Chinese plug-ins
because PyCharm Go in English , So after downloading this Chinese plugin , Restart will display Chinese status
.
open File->Settings… Will jump out of the window

In the choice “marketplace” Then type... In the input box “Chinese” After that, you can find the Chinese plug-in , Click on “install” Download


Click restart

[ pip Use ]

Suppose I want to install Selenium
Selenium It's easy to install , This can be done as follows .

pip install selenium


Enter directly through the command window , There is no need to enter python The command line of the environment , Then enter the above statement to selenium Installation .

Selenium Once installed ,python It can't be used directly , It needs to dock with the browser . Here Chrome Browser as an example . If you want to use Selenium A successful call Chrome Browser to complete the corresponding operation , Need to pass through ChromeDriver To drive .

link :http://npm.taobao.org/mirrors/chromedriver/
or https://chromedriver.storage.googleapis.com/index.html
( The version should be the same as Google version )

My is 86.0.4240 You have to download this version




When the download is complete , Unzip and copy to python The root directory of the environment Under the folder

And through cmd Command line run chromedriver, If you don't report a mistake, you will succeed

pip Version update

python -m pip install --upgrade pip

Be careful : Don't need to python The command line of the environment , But use cmd Updates from the command line


  1. 上一篇文章:
  2. 下一篇文章:
Copyright © 程式師世界 All Rights Reserved