Python generates QR code qrcode and problems

Source: Internet
Author: User
Php Chinese network (www.php.cn) provides the most comprehensive basic tutorial on programming technology, introducing HTML, CSS, Javascript, Python, Java, Ruby, C, PHP, basic knowledge of MySQL and other programming languages. At the same time, this site also provides a large number of online instances, through which you can better learn programming... Generate a QR code using qrcode

Code used for online tutorials

Simple and crude

Import qrcode img = qrcode. make ('http: // lizhiyu.iteye.com/blog/2336662') img.save('test.png ') and parameters control Python code import qrcode qr = qrcode. QRCode (version = 1, error_correction = qrcode. constants. ERROR_CORRECT_L, box_size = 10, border = 4,) qr. add_data ('http: // lizhiyu.iteye.com/') qr. make (fit = True) img = qr. make_image () img.save('123.png ')

Parameter description:
Version: The value ranges from 1 ~ The integer of 40, which controls the size of the QR code (the minimum value is 1, which is a 12 × 12 matrix ). If you want the program to determine automatically, set the value to None and use the fit parameter.

Error_correction: Controls the error correction function of the QR code. You can set the following four constants.
ERROR_CORRECT_L: Errors of about 7% or fewer can be corrected.
ERROR_CORRECT_M (default): Errors of about 15% or fewer can be corrected.
ROR_CORRECT_H: Errors of about 30% or fewer can be corrected.

Box_size: controls the number of workers contained in each small grid in the QR code.

Border: number of cells contained in the control border (the distance between the QR code and the image boundary) (default value: 4, which is the minimum value specified by relevant standards)

Problem 1. a classic error occurs. the file name uses the keyword qrcode. py and the file name is changed to aaa. py.

AttributeError: 'module' object has no attribute 'make'

Problem 2. after modification, the following error is still reported. you need to install the PilImage package.

Traceback (most recent call last): File "E: \ python_test \ qrtest \ aaa. py", line 3, in
 
  
Img = qrcode. make ('http: // www.xgezhang.com/') File "C: \ Python27 \ lib \ site-packages \ qrcode \ main. py ", line 11, in make return qr. make_image () File "C: \ Python27 \ lib \ site-packages \ qrcode \ main. py ", line 271, in make_image from qrcode. image. pil import PilImage File "C: \ Python27 \ lib \ site-packages \ qrcode \ image \ pil. py ", line 8, in
  
   
Import Image ImportError: No module named Image problem 3.pip install PilImage error. because of the windows environment write tool, you can directly download the exe file on the piliage website for execution, solve cocould not find a version that satisfies the requirement PilImage (from versions :)
  
 

No matching distribution found for PilImage

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.