Je suis nouveau sur python, et j'ai trouvé sur github ce projet "https://github.com/jadsonbr/pyreport", je veux imprimer des factures à partir d'un serveur mysql. Je l'ai installé et pyreport jasperpy mais lorsque je tente d'exécuter le code que je reçois cette erreur:pyreport et jasperpy, j'ai une erreur avec l'exécution du code
Traceback (most recent call last):
File "E:/onedrive/Documents/optimpos/module/fact_print.py", line 36, in <module>
compiling()
File "E:/onedrive/Documents/optimpos/module/fact_print.py", line 9, in compiling
jasper = pyjasper.JasperPy()
AttributeError: 'module' object has no attribute 'JasperPy'
Mon fact_print.py ressemble à ceci:
import os,sys,subprocess
from platform import python_version
import pyjasper
sys.stderr = open("errlog.txt", "w")
def compiling():
input_file = os.path.dirname(os.path.abspath(__file__)) + \
'/Invoice_2.jrxml'
jasper = pyjasper.JasperPy()
jasper.compile(input_file)
def advanced_example_using_database():
input_file = os.path.dirname(os.path.abspath(__file__)) + \
'/Invoice_2.jrxml'
output = os.path.dirname(os.path.abspath(__file__)) + '/'
con = {
'driver': 'mysql',
'username': 'admin1',
'password': 'marcopolo',
'host': 'localhost',
'database': 'optimpos',
'schema': 'temp_vanzari',
'port': '3306'
}
jasper = pyjasper.JasperPy()
jasper.process(
input_file,
output_file=output,
format_list=["pdf", "rtf", "xml"],
parameters={'python_version': python_version()},
db_connection=con,
locale='en_US' # LOCALE Ex.:(en_US, de_GE)
)
print("done printing")
Il est peut-être une réponse facile, mais je n'étais pas en mesure pour trouver pourquoi le pyjasper.JasperPy()
ne fonctionnera pas. J'utilise pyhton 2.7
Ceci est juste un code de test, le serveur mysql est juste pour le test. Besoin d'aide, et merci
Copie possible de [AttributeError: l'objet 'module' n'a aucun attribut] (https://stackoverflow.com/questions/1250103/attributeerror-module-object-has-no-attribute) & [Python AttributeError: 'module' l'objet n'a pas d'attribut 'Serial'] (https://stackoverflow.com/q/11403932/876298) –