Install third-party libraries, modules, and packages in Python

Source: Internet
Author: User

Install third-party libraries, modules, and packages in Python
Many useful modules have been built in python. Once python development tools are installed, these modules can be used immediately. In the actual python development process, in addition to the python built-in modules, python also has a large number of third-party libraries, modules and packages. Common third modules are registered on python's PyPI-the Python Package Index. You only need to find the name of the corresponding module and install it. Recently, we need to use python to create PDF documents. However, because python has built-in modules, we need to use a third-party reportlab library to create PDF documents. Since the third-party library was installed for the first time, it took a long time to complete the installation methods.
1. Currently, the Installation Tool for python is usually steup. py or pip. pip is recommended in python. Versions later than python3.4 contain pip by default. Use a windows system, python development tool install to C: \ Python33 directory (1) install pip in order to install pip, first download the get-pip.py script and then execute the get-pip.py script to install pip. Get-pip.py Script: get-pip.py. Put the get-pip.py script in the C: \ Python33 \ Tool directory, you can also put it in another directory. Run the: python get-pip.py in cmd to install the pip tool after you execute this command. The get-pip.py supports other options that can be installed directly by default. (2) pip update: python-m pip install-U pip
(3) Add the environment variable pip and install pip.exe in C: \ Python33 \ scripts. to facilitate pip running in cmd, add the pip path "C: \ Python33 \ Scripts" to the environment variable path ".
2. Install a third-party module. Find the name of the reportlab module in pypi. The name of reportlab is reportlab 3.1.44. environment variables can be directly used. Run pip install reportlab in cmd. Due to the credit of GFW, The reportla module has been successfully installed after execution. If the installation times out or fails, run the command again. After successful execution, check C: \ Python33 \ Lib \ site-packages and you will find that the reportlab directory is missing. Now you can use the reportlab module.

#!/usr/bin/python#FileName creatPDF.pyfrom reportlab.pdfgen import canvasdef creatPDF(c):    c.drawString(100, 100, "using reportlab")c = canvas.Canvas("test.pdf")creatPDF(c)c.showPage()c.save()
After the execution, a testbench is created, with the content "using reportlab"

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.