2017-04-17 6 views
0

私はWindows 10マシンでPython 3.6を実行しており、pythonから直接PNGとしてQRコードのバッチを作成したいと考えています。 qrcodeを使用して、100〜200個の個別QRコードのバッチを作成します。差し込み印刷でイメージが使用され、個々のドキュメントが作成されます。 qr.exeスクリプトを使用して個々の画像を作成することはできますが、Python内でQRコードPNGを作成することはできません。Python 3.6でqrcodeを使ってイメージとしてQRコードのバッチを作成する

qrcodeのドキュメントを読んでいるうちに、「Pure Python PNG」が正常に動作するようになりました(https://github.com/lincolnloop/python-qrcode/blob/master/README.rst)。具体的に

、私はgitの+ gitのインストールPIPコマンドプロンプト

でPIPを使用してpymagingインストールしよう:gitの+のgitをインストールするPIP を//github.com/ojii/pymaging.git#egg=pymagingを: //github.com/ojii/pymaging-png.git#egg=pymaging-png

私が手

はgitの+のgitからpymaging収集次のレポート://githumb.com/ojii/pymaging.git #egg = pymaging git://github.com/ojii/pymaging.gitをc:\ Users \ B \ AppDataq \ Local \ Temp \ pip-build-jioh63js \ pymagingにコピーする

は、それから私は、次のようなエラーに

エラー[WinError 2]指定されたファイルを見つけることができないシステムを取得し実行するコマンドgitのクローンgitの-q中://github.com/ojii/pymaging.git C:\ユーザー\ B \ AppDataq \ Local \ Temp \ pip-build-jioh63js \ pymaging コマンド 'git'を見つけることができません

私はtempフォルダを見ていますが、pip *フォルダは表示されません。 pymagingをインストールする方法の提案はありますか?

- 更新 -

のgitがインストールされると、コマンドはgitののはbashから実行することができ、pymagingがインストールされています。

+0

'git'がインストールされていますか? – corn3lius

+0

ありがとう! gitの最新バージョンをダウンロードし、git bashからpymagingをインストールすることができました。 – bob1029

答えて

0

QRコードのバッチをPython 3でイメージとして作成するためのドキュメントは少しスリムで、具体的には実際のイメージファイル(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). 
関連する問題