Baptism soul, practice python (2) -- python installation and configuration, python -- python

Source: Internet
Author: User

Baptism soul, practice python (2) -- python installation and configuration, python -- python

Install python and basic configurations:

Python Official Website: www.python.org

 

Open the website and download the corresponding version (32-bit and 64-bit, windows or linux). You can select python3 or 2. Currently, many enterprises use python2. Why? BecauseCurrently (pay attention to the posting time of my blog posts)Many third-party modules support and better cooperate with python2, which is not compatible with many modules. However, there is a problem. The official python suggestions are for you to use version 3, because in 2020, python2 will stop providing services and will not be maintained. python2.7 is also the last version of python2, at the same time, the module supported by python2 is now being transferred to version 3. In other words, python3 will support all modules in the near future, and python2 will not be updated, no service or maintenance at the same time.

In fact, you should have a question: why is there another python 3 with Python 2, which is inexplicably updated directly on version 2?

A: I personally understand that python2 has many similar functions and even the same modules. He wants to integrate these functions and delete unnecessary functions. If no new functions are available, add them, however, most enterprises still use version 2, which is the same now. Therefore, if you change the data directly on version 2, the scale and running mode of basically stable enterprises also need to be changed. This involves many problems. How can this problem be solved? Therefore, the python3 and python3 integrate similar or similar functions, such as syntaxes, keywords, and modules, and are no longer as messy as version 2, this is like IPV4 and IPV6 (network protocol). version 6 has been available for a long time, but now we are still using version 4, which is the same problem. If you switch to version 6, there are a lot of problems involved, because enterprise servers cannot be artificially down without accidents. If a server goes down for a second, it will lose a lot of money, which we can't imagine, this problem has been stranded. [In this case, when IPV6 appeared, it was like on the beach. IPV6 uses a hexadecimal system to allocate an IP address to every sand in the beach, in fact, IPV6 is also basically getting nothing left (/manual funny), as long as you have money, you can buy an IP address, there is no rule that one person can only have one IP address, maybe one IP address pool, or multiple IP address pools. Well, keep going .]

How can I install the SDK after the download? Next, we will see that my system environment is 64-bit in Windows 7. Double-click to run it, and then see the figure.

 

During installation, select here. In this way, the installer automatically adds the environment variable of the python program to the path environment variable of the system without manual setup. Click next (next.

Manual setting: Right-click the desktop computer (or my computer, this computer, this computer) icon-properties-computer-advanced system settings-environment variables under the Advanced tab-find the 'path' variable in the system variables and install the python path (for example, C: \ Python27 \ python.exe) copy and paste it and separate it with an existing parameter with a semicolon (;). Save and exit.

After the installation is complete, you can directly run python in cmd (Start Menu-run-enter 'cmd', and press Enter ).

And enter quit () or exit () to exit.

The method for installing python3 is the same:

Then the other settings are directly set by default, and the installation is complete (run the same method as python2 in cmd)

 

Can I install multiple python versions on one computer?

A: Yes. Multiple versions do not conflict with each other. You can switch between different versions to run python code.

 

But after installing multiple versions, there are several problems:

Question 1, How to set the Python version opened by right-clicking the "Edit with IDLE" free option

A:

1. Enter regedit at the run to enter the registry;

2. Find the [HKEY_CLASSES_ROOT \ Python. File \ shell \ Edit with IDLE \ command]

3. Changed "data" to Python27

4. Double-click (default) and change the value :"Your python 3 installation path(For example, C: \ python34 \ pythonw.exe) "C: \ python34 \ Lib \ idlelib \ idle. pyw"-e "% 1"

 

What is IDLE?

A: It is a graphical interface IDE (editor) that comes with python. You can write your code on it.

It is important to select a good IDE.

After installation, you can directly start the python program at the Windows command prompt, that is, CMD.

 

Question 2, How to specify the program to double-click to open the. py file (the Special suffix format of the python code file, like the c code file is '. C?

A:

1. Enter regedit at the run to enter the registry;

2. Find the [HKEY_CLASSES_ROOT \ Python. File \ shell \ open \ command]

3. Double-click (default) and change the value to "C: \ Python34 \ python.exe" "% 1" % * (here I want to double-click to open it with Python3.4 ).

4. c: \ Python34; C: \ Python34 \ Scripts add to environment variables (right-click "this computer"> "Advanced System settings"> "environment variables (N )... ).

 

Question 3How to set the shortcut menu for multiple versions:

In the Registry: HKEY_CLASSES_ROOT \ Python. in File \ shell \, create a new item "Run Through Python2.7", and then create a new item "command". Set the default value to "C: \ Python27 \ python.exe" "% 1" % *.

If the script needs to use Python2.7, right-click the script and choose execute.

Question 4, How to set the version to run in cmd:

Input Python in command line mode. The default is to execute Python2.7:

 

Go to python3 (you do not need to set the environment variables and registry at this time, and the setting is useless. We recommend that you do not change the main program name, for example, the path lC: \ Python \ Handler name has changed. And there is no need to change), directly py-2 or py-3:

Python has a powerful open-source pypi community. Many of them provide many original python third-party libraries. You can use the pip install .. command to install third-party libraries,When there are multiple versions of python at the same time, the original Command will not be able to get the desired result. Intelligent Display of a default python version. If this version is just what we want, we can say that, if not? For example, the default version is python3. What if I want to install it on python2? So you need a command to install different versions to different python versions, py-2-m pip install... Or pip2 install:

Similarly, enter py-3-m pip install... Or pip3 install... Install

Uninstall third-party Library: pip uninstall. Other keywords are the same as those for installation.

 

When a beginner sees this, it's estimated that all of them are running the same command: I rely on it, install python, change the environment variable, and change the Registry. This is really annoying.

 

After hearing the news from the python official website, I think this needs to be improved. Therefore, starting from version 3.6, if you have installed versions 2.7 and 3.6, the above problems have already been solved by default when you install Python 3.6. Is it so powerful? Yes, the python official team is so user-friendly. If you have any requirements, they should be mentioned. This is also one of the purposes of the emergence of the python language (if a friend directly skips the previous section to see it here, I want to say, you're lucky)

 

However, to install python3.6, note the following:

1. Install the windows Patch sp1 before installing Python 3. Link: https://www.microsoft.com/zh-cn/download/details.aspx? Id = 5842 (if the link is invalid, go to the Microsoft official website or Baidu to search for it)

2. After selecting the environment variables, remember to check the selected options so that you can install them for all users. Otherwise, other users do not have the permission to run python3 after logging on to the local machine.

Other operations remain unchanged

After python3.6 and 2.7 are installed, there will be two versions of IDLE. When I install python3.6.1, it will automatically set the shortcut key in the right-click menu. See:

 

So far, our prerequisite work has been completed, and we will wait for the project to start.

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.