2017-04-17 2 views
0

나는 파이썬 3.6을 Windows 10 머신에서 실행 중이며 python에서 직접 PNG로 QR 코드의 배치를 만들고 싶습니다. qrcode를 사용하여 100 ~ 200 개의 개별 QR 코드 배치를 만듭니다. 이미지는 편지 병합에서 개별 문서를 만드는 데 사용됩니다. qr.exe 스크립트를 사용하여 개별 이미지를 만들 수는 있지만 Python 내에서 QR 코드 PNG를 만들 수는 없습니다.파이썬 3.6에서 qrcode를 사용하여 QR 코드의 배치를 이미지로 생성

qrcode에 대한 설명서를 읽는 동안 "Pure Python PNG"가 작동하는 데 문제가 있습니다 (https://github.com/lincolnloop/python-qrcode/blob/master/README.rst). 특히

, 내가 자식 + 자식 설치 PIP 명령 프롬프트

에서 PIP를 사용 pymaging 설치하려고 : 자식 + 자식을 설치 PIP 을 //github.com/ojii/pymaging.git#egg=pymaging를 : //github.com/ojii/pymaging-png.git#egg=pymaging-png

내가 얻을

이 자식 + 자식에서 pymaging 수집 다음 보고서 : //githumb.com/ojii/pymaging.git # egg = pymaging c : \ Users \ B \ AppDataq \ Local \ Temp \ pip-build-jioh63js \ pymaging에 자식 git : //github.com/ojii/pymaging.git 복제

은 그 때 나는 다음과 같은 오류를

오류 [WinError 2] 지정된 파일을 찾을 수 없습니다 얻을 실행 명령 자식 클론 -q 자식 동안 : //github.com/ojii/pymaging.git C : \ 사용자 \ B \ AppDataq \ Local \ Temp \ pip-build-jioh63js \ pymaging 'git'명령을 찾을 수 없습니다

임시 폴더를보고 pip * 폴더를 볼 수 없습니다. pymaging을 설치하는 방법에 대한 제안 사항이 있습니까?

- 업데이트 -

자식은 명령이 자식의 떠들썩한 파티에서 실행할 수 있으며 pymaging가 설치되어 설치되면.

+0

'git'이 설치되어 있습니까? – corn3lius

+0

감사! 가장 최근 버전의 git을 다운로드했고, git bash에서 pymaging을 설치할 수있었습니다. – bob1029

답변

0

Python 3에서 이미지로 QR 코드 일괄 처리를 만드는 데 필요한 설명서가 조금 슬림했습니다. 구체적으로 실제 이미지 파일 (see qrcode 5.3 documentation)을 작성하는 마지막 단계 였으므로 수정 한 일부 코드를 공유하려고했습니다. Python 2.7의 원래 코드는 prasopensource's blog입니다. 아래는 Python 3.6 용으로 만든 스크립트입니다.

import qrcode, os.path 
print('What is the name of the file containing the data for the QR codes?') 
fname = input().strip() 
file = open(fname, "r") 
print() 
for x in file: 
    x = x.rstrip() 
    qr = qrcode.QRCode(version=1, error_correction=qrcode.constants.ERROR_CORRECT_L,box_size=10,border=4,) 
    qr.add_data(x) 
    qr.make(fit=True) 
    img = qr.make_image() 
    file_name = x + ".png" 
    print('Saving %s' % file_name) 
    image_file = open(file_name, "w") 
    img.save(file_name) 
    image_file.close() 
file.close() 

# INFORMATION ABOUT QRCode SETTINGS 
#The version parameter is an integer from 1 to 40 that controls the size of the QR Code (the smallest, version 1, is a 21x21 matrix). Set to None and use the fit parameter when making the code to determine this automatically. 

#The error_correction parameter controls the error correction used for the QR Code. The following four constants are made available on the qrcode package: 
#ERROR_CORRECT_L 
#About 7% or less errors can be corrected. 
#ERROR_CORRECT_M (default) 
#About 15% or less errors can be corrected. 
#ERROR_CORRECT_Q 
#About 25% or less errors can be corrected. 
#ERROR_CORRECT_H. 
#About 30% or less errors can be corrected. 

#The box_size parameter controls how many pixels each “box” of the QR code is. 

#The border parameter controls how many boxes thick the border should be (the default is 4, which is the minimum according to the specs).