How Python installs third-party modules

Source: Internet
Author: User

in thepython Development , how do I install the python module? Certainly many beginners are wondering why install the module? becausethese modulesinis not included in python 's default code and needs to be downloaded and installed externally. For example , pygame version of Windows , directly double-click the installation can. However, most modules do not provide such a way of installation, some students failed to install the installation can not be introduced into the program module. Here, we introduce Several common installation methods of Python module.
1. Direct copy
The downloaded module file already has the module file, some modules have only one file, such as the earlier version of the BeautifulSoup, some are a folder, such as the new version BeautifulSoup is a call BS4 the folder.
Copy These files directly to the /lib/site-packages under your python path. folder, such as c:/python27/lib/site-packages . You can then refer directly to the program:
import BeautifulSoup or from bs4 import BeautifulSoup
This is determined by the location of the files you place.
Some people on the internet say that they can be placed directly in the Lib folder. Yes, it does, but the Lib folder is the module that comes with it, and we'll see the code files of the random,re and other modules we used. External modules are generally placed in the site-packages folder.
2.setup.py
many modules are included with the setup.py file, a classmate directly double-clicked, and then found no use.
It is used to run from the command line to the path where the setup.py is located.
python setup.py Install
Take a closer look at the output of the installation information can be found that the command to do the thing is to help you copy the module code to the site-packages folder.
3.setuptools
using setuptools , you can automatically download the installation directly according to the module name, without needing to find the module installation files yourself. But before you use it, you have to install setuptools itself.  
The Windows platform of the setuptools python, you can directly download the EXE file installation. (Go to search setuptools Windows can be found, I also uploaded a copy in the forum after this post)
Linux users can be installed from the package manager, such as ubuntu:
apt-get Install Python-setuptools
The Windows platform , python , has to be installed with ez_setup.py (Files I've uploaded). This approach also applies to all platforms.
run in the folder where ez_setup.py is located:
python ez_setup.py
the Setuptools will be installed under the python path \scripts . You can then add this path to the environment variable path , or you can go directly from the command line to the Scripts folder and execute the easy_ Install to see if the installation is successful.
after that, you can use it directly to install the modules you want, such as PIL:
Easy_install PIL
The video tutorial program will help you download and install the site-packages automatically .  
Finally, introduce several good modules for your reference.
PIL- graphics processing
PyXML- parsing and processing XML files
MySQLdb- connect to MySQL database
Tkinter- GUI interface,python comes with
smtplib- send e-mail
ftplib-ftp Programming
Pymedia- multimedia operations
Pyopengl-opengl Interface
parser for beautifulsoup-html/xml

above is python installs the module in a way that hopes to help friends who are learning python .


How Python installs third-party modules

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.