Я создал сценарий python для окон, чтобы печатать каждый файл в каталоге. Для этого я использую ghostscript и gsprint.Файл не найден Ошибка с python, нет ошибки в cmd
Когда я запустить скрипт, есть ошибка WindowsError: [error2] file not found
Если я запустить ту же командную строку в ЦМД, нет никакой ошибки, и PDF напечатан ...
вот мой сценарий:
for f_name in files_in_dir:
fullpath_file = os.path.join(base_print, path_print_source, f_name)
carrier = f_name.split('-')[0]
new_path = os.path.join(base_print, carrier + '_printed')
new_fullpath_file = os.path.join(new_path, f_name)
print Tools.format_txt("traitement du fichier %s" % f_name)
print Tools.format_txt("traitement du fichier %s" % f_name, carrier)
p = subprocess.Popen(['gsprint', '-printer', printer,'-dPDFFitPage', fullpath_file], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
out, err = p.communicate()
if out:
print Tools.format_txt(out)
if err:
print Tools.format_txt(err, level="error")
print Tools.format_txt("fichier %s envoyé pour impression" % f_name, carrier)
if not os.path.exists(new_path):
os.makedirs(new_path)
os.rename(fullpath_file, new_fullpath_file)
созданный путь для файла: C:\Users\GREG\Downloads\DHL-575555338523255087006833669.pdf
отслеживающий:
Traceback (most recent call last):
File "python-print.py", line 95, in <module>
sys.exit(main()) # si le script est utilis├® comme un module, on n'ex├®cute pas le script
File "python-print.py", line 61, in main
p = subprocess.Popen(['gsprint', '-printer', printer,'-dPDFFitPage', fullpath_file], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
File "C:\Python27\lib\subprocess.py", line 710, in __init__
errread, errwrite)
File "C:\Python27\lib\subprocess.py", line 958, in _execute_child
startupinfo)
WindowsError: [Error 2] Le fichier spÚcifiÚ est introuvable
Я использую Windows 10 с питоном 2,7
Как запустить сценарий? Является ли 'gsprint' в PATH? – syntonym
yes gsprint находится на пути –
скрипт запущен без простоя - отредактируйте: с cmd it-the same –