Installing Python is easy, but many of the details may not be obvious. Document the whole process while installing the latest version 3.8.
Python or Anaconda
This section is written for people who don’t understand Python until someone drops the phrase “Install Anaconda”.
If you haven’t heard of Anaconda, skip this section.
It’s clear what Anaconda is, so skip this article.
The word Anaconda, like Python, means Python. It is a Python distribution for scientific computing. A distribution, known as an enhancement, is a bundle of commonly used tools and libraries.
So Anaconda is much bigger than Python.
Although it contains many mature and useful tools, it does more harm than good for beginners to learn Python. Therefore, it is not recommended for newcomers to install.
Once you’ve mastered Python, you can use it when you need to.
”
One of the tools, Jupyter, is a useful tool for teaching and we will introduce it separately at the appropriate time.
32-bit or 64-bit
Go to the Python website: python.org, and the default download button provides a 32-bit installation package.
Most of the time, especially during the learning phase, there is no difference between 32-bit and 64-bit. All Python code we write from now on won’t be bitwise.
The Python you’re using today is CPython, which uses modules written in C directly. These C modules compile results for Python with different bits only for specific versions.
In most cases, these modules provide versions for different bits at the same time, which are automatically matched when using PIP Install directly. However, when manually downloading the installation package, pay attention to the version match. Such as:
Even if special circumstances later require a particular version of Python, just reinstall it, so we don’t have to worry too much about it here. People like me who are obsessive-compulsive have to choose one that is compatible with the operating system.
”
Careful observers may have noticed that there are different forms of representation for 64-bit, x86-64 and AMD64, mainly for historical reasons. Have interest can search to know by oneself.
Add Python to PATH
Start the installation
All Python installation tutorials will highlight this check
Add Python to PATH
But here comes the question:
If this option is so important, why doesn’t the installation package make it the default check?
If you are careful, you will also notice that there is an option: Install Launcher for all users(recommended)
Not only has the default ticked treatment, but also bracket, recommended. In case you don’t choose it.
Who is the launcher, and why is it higher in priority than PATH?
Why install launcher by default
The role of the PATH
First, the value of the environment variable PATH is a list of paths. Since the value of the environment variable only supports strings, use the semicolon (;). The form of the connection string.
”
Windows 10 is a good experience, with dialog-like list operations. Windows 7 also requires editing the entire string
When we type commands on the command line, the operating system searches these paths for executable programs that match the number. As long as it is found, it is executed; If not found, report an error.
When looking for is the order from front to back, once found, behind do not continue to look.
Therefore, in order for the command line to find Python, the python installation PATH must also be added to the PATH variable, which is no surprise.
The problem is that Python is not always installed. Sometimes we have to install multiple versions of Python.
The pain point of having multiple Python versions
For example, although today we have the latest Python version 3.8 installed, I may need to use software that is not that new, or even enterprise software that only supports Python 2.7.
Installing multiple Versions of Python in different directories does not conflict with each other, but only one can be added to PATH. Other Python not added to PATH becomes less convenient to use.
On Linux, this is easy to solve, but on Windows, it’s a hassle, and that’s where the Python launcher comes in.
The Python launcher is also a program, py.exe, that can be called by typing py directly on the command line. It makes it easy to manage all installed Versions of Python and easily start different versions of Python interpreters, whether or not they are added to PATH.
Slackers can click Install Now after checking Add Python to PATH to start the installation. For introduction purposes, or if you want to install Python into a custom directory, you can choose Customize Installation.
Other options
Custom installation has two dialog boxes to select, the first one is checked by default, the meaning of each option is described as follows:
-
Documentation of offline
.chm
Format document, must be retained. English also
OK
Friends can read this document directly, more reliable than all the books. If you are under pressure to read English, it is good to check the usage of standard library modules. -
PIP Python package download tool, must be retained. (Want to find a sadistic casual)
-
TCL/TK and IDLE, it’s a long story.
-
Python Test Suite, this can be done without, of course, it is ok to stay.
-
Py Launcher, you’ve seen that before. The extra thing to notice here
for all user
Option to choose whether to install for all users. If installed for all users, yes
administrator
The permissions.
The second dialog is for advanced options:
-
Install for all user, whether to Install for all. If yes, yes
administrator
And the installation path will be different. -
Associate the file to Python and leave it as it is. It is the
.py
Files and
python
Program associated with this double click
.py
When you file, it’s automatically used
python
To execute. -
Create a shortcut and leave it as it is.
-
Add Python to environment variables, second chance for modification
-
Precompiled standard library, a one-time standard library
.py
It’s all precompiled
.pyc
, not necessary, will take more time to install, do not choose -
Download debug XXX (download debug XXX
At the bottom is to specify the installation path, personal opinion, keep the default. If you uncheck install for everyone, the default installation path is a bit deeper, which looks uncomfortable, but most of the time we don’t visit that directory directly, so it doesn’t matter.
”
My personal recommendation is not to install for all users, so that if you want to use multiple users, each user has the freedom to choose.
Basic testing after installation
Once the installation is complete, open a new command line window, win + r, and type CMD:
”
Note that it must be reopened; command lines that were opened before installing Python do not automatically update environment variables.
Execute the following commands in sequence:
# Note that -0 is followed by the number 0, not the letter OPy minus 0 or py --listCopy the code
This is the call to the Python launcher, which displays the installed version of Python on the system.
python --version
Copy the code
This is a direct call to the Python interpreter, printing out its version.
pip --version
Copy the code
This is to call PIP and print out its version.
The reason for testing these three commands is that they are installed in different locations and all work correctly, which proves that the installation is ok.
For more details, look at the PATH environment variable.
PATH changes after installation
Since the installation was not selected for all users, the environment variable looks at the current user’s:
”
Depending on how you choose to install, the location of the environment variable will vary
The above three items are automatically added after installation.
”
Note that if the launcher is not unchecked for all user, it is installed in the system directory by default, so there is no need to add it to the PATH. There are only two new ones.
Installation Directory Details
C:\Users\Davy\AppData\Local\Programs\Python\Python38, which is the installation path of Python, is the directory containing python.exe.
Functions of other directories:
-
DLLs, static link libraries, and there are some
.dll
和
.pyd
Files, you don’t normally deal with this directory directly -
Doc is one of them
python381.chm
The shortcut contains the document path, so it is not normally accessed directly -
Include, header files, you’re not going to use them
-
LibThis directory is the most important. It contains almost all library source code, and most of it is left untouched, except for one subdirectory:
-
site-packagesSubsequent third party modules and packages will be installed here, so we will visit here when problems occur.
-
-
Libs, almost never directly used, pay attention to and
Lib
Separate. (Because Windows paths are case insensitive, Lib is actually displayed as Lib) -
ScriptsThis is where the executable file will appear if a command is provided by a subsequent installed third-party package. For example,
pip.exe
It is in this directory that the PIP source code is stored in Lib. -
TCL, again, is a long story. I’ll skip it
-
Tools, which comes with some Python scripts, including some
demo
Some of them can be used as reference for study.
Finally, look at the directory for the Launcher, which manages all Python versions, so it is detached and installed in the parent directory of Python38.
Launch Menu Details
After installing Python, there are four more shortcuts in the Start menu, which are rarely used. A brief introduction:
-
IDLE (Python 3.8 64-bit), used to start IDLE, more on this later.
-
Python 3.8 Module Docs (64-bit), clicking on it will automatically launch a local Web service, which will then automatically open a page containing the Module’s documentation. The style is very old and the contents are contained in the documentation file below, so almost no one will use this.
-
Python 3.8 Manuals (64-bit), click to open the documentation
-
Python 3.8 (64-bit), click to start the Python interpreter. When the interpreter is started this way, the entire black window disappears and the printed information is not visible, so we usually start The command line first and then start Python from the command line, so that we can see the result of the program execution even when the interpreter exits.
summary
This article explains the considerations of installing Python in detail, and details the role of each folder after installation, as well as the three additional commands.
If this article has been helpful to you, please like, share and follow. Thank you!