为什么我本地python运行可以成功,放yd里报pandas错
回答
收藏

为什么我本地python运行可以成功,放yd里报pandas错

m
murder089
2025-01-02 12:31·浏览量:297
m
murder089
发布于 2025-01-02 12:31297浏览

('文件转换失败,失败原因:', Exception('文件从csv转excel失败I/O operation on closed file.'))

Traceback (most recent call last):

 File "C:\Program Files (x86)\ShadowBot\shadowbot-5.16.50\python\lib\xml\etree\ElementTree.py", line 836, in _get_writer

   yield file.write

 File "C:\Program Files (x86)\ShadowBot\shadowbot-5.16.50\python\lib\xml\etree\ElementTree.py", line 777, in write

   short_empty_elements=short_empty_elements)

 File "C:\Program Files (x86)\ShadowBot\shadowbot-5.16.50\python\lib\xml\etree\ElementTree.py", line 942, in _serialize_xml

   short_empty_elements=short_empty_elements)

 File "C:\Program Files (x86)\ShadowBot\shadowbot-5.16.50\python\lib\xml\etree\ElementTree.py", line 942, in _serialize_xml

   short_empty_elements=short_empty_elements)

 File "C:\Program Files (x86)\ShadowBot\shadowbot-5.16.50\python\lib\xml\etree\ElementTree.py", line 942, in _serialize_xml

   short_empty_elements=short_empty_elements)

 [Previous line repeated 2 more times]

 File "C:\Program Files (x86)\ShadowBot\shadowbot-5.16.50\python\lib\xml\etree\ElementTree.py", line 939, in _serialize_xml

   write(_escape_cdata(text))

MemoryError


During handling of the above exception, another exception occurred:


Traceback (most recent call last):

 File "C:\Users\Administrator\AppData\Local\ShadowBot\users\65235345841459200\apps\53eb3f79-5e62-4bde-a55d-02a4225d3bff\xbot_robot\download_file.py", line 80, in get_to_excel

   df.to_excel(export_file_path, index=False)

 File "C:\Users\Administrator\AppData\Local\ShadowBot\users\65235345841459200\apps\53eb3f79-5e62-4bde-a55d-02a4225d3bff\venv\lib\site-packages\pandas\core\generic.py", line 2291, in to_excel

   storage_options=storage_options,

 File "C:\Users\Administrator\AppData\Local\ShadowBot\users\65235345841459200\apps\53eb3f79-5e62-4bde-a55d-02a4225d3bff\venv\lib\site-packages\pandas\io\formats\excel.py", line 850, in write

   writer.close()

 File "C:\Users\Administrator\AppData\Local\ShadowBot\users\65235345841459200\apps\53eb3f79-5e62-4bde-a55d-02a4225d3bff\venv\lib\site-packages\pandas\io\excel\_base.py", line 1024, in close

   content = self.save()

 File "C:\Users\Administrator\AppData\Local\ShadowBot\users\65235345841459200\apps\53eb3f79-5e62-4bde-a55d-02a4225d3bff\venv\lib\site-packages\pandas\io\excel\_openpyxl.py", line 80, in save

   self.book.save(self.handles.handle)

 File "C:\Program Files (x86)\ShadowBot\shadowbot-5.16.50\python\lib\site-packages\openpyxl\workbook\workbook.py", line 408, in save

   save_workbook(self, filename)

 File "C:\Program Files (x86)\ShadowBot\shadowbot-5.16.50\python\lib\site-packages\openpyxl\writer\excel.py", line 293, in save_workbook

   writer.save()

 File "C:\Program Files (x86)\ShadowBot\shadowbot-5.16.50\python\lib\site-packages\openpyxl\writer\excel.py", line 275, in save

   self.write_data()

 File "C:\Program Files (x86)\ShadowBot\shadowbot-5.16.50\python\lib\site-packages\openpyxl\writer\excel.py", line 75, in write_data

   self._write_worksheets()

 File "C:\Program Files (x86)\ShadowBot\shadowbot-5.16.50\python\lib\site-packages\openpyxl\writer\excel.py", line 215, in _write_worksheets

   self.write_worksheet(ws)

 File "C:\Program Files (x86)\ShadowBot\shadowbot-5.16.50\python\lib\site-packages\openpyxl\writer\excel.py", line 200, in write_worksheet

   writer.write()

 File "C:\Program Files (x86)\ShadowBot\shadowbot-5.16.50\python\lib\site-packages\openpyxl\worksheet\_writer.py", line 358, in write

   self.close()

 File "C:\Program Files (x86)\ShadowBot\shadowbot-5.16.50\python\lib\site-packages\openpyxl\worksheet\_writer.py", line 366, in close

   self.xf.close()

 File "C:\Program Files (x86)\ShadowBot\shadowbot-5.16.50\python\lib\site-packages\openpyxl\worksheet\_writer.py", line 297, in get_stream

   pass

 File "C:\Program Files (x86)\ShadowBot\shadowbot-5.16.50\python\lib\contextlib.py", line 119, in __exit__

   next(self.gen)

 File "C:\Program Files (x86)\ShadowBot\shadowbot-5.16.50\python\lib\site-packages\et_xmlfile\xmlfile.py", line 50, in element

   self._write_element(el)

 File "C:\Program Files (x86)\ShadowBot\shadowbot-5.16.50\python\lib\site-packages\et_xmlfile\xmlfile.py", line 77, in _write_element

   xml = tostring(element)

 File "C:\Program Files (x86)\ShadowBot\shadowbot-5.16.50\python\lib\xml\etree\ElementTree.py", line 1136, in tostring

   short_empty_elements=short_empty_elements)

 File "C:\Program Files (x86)\ShadowBot\shadowbot-5.16.50\python\lib\xml\etree\ElementTree.py", line 777, in write

   short_empty_elements=short_empty_elements)

 File "C:\Program Files (x86)\ShadowBot\shadowbot-5.16.50\python\lib\contextlib.py", line 130, in __exit__

   self.gen.throw(type, value, traceback)

 File "C:\Program Files (x86)\ShadowBot\shadowbot-5.16.50\python\lib\xml\etree\ElementTree.py", line 836, in _get_writer

   yield file.write

 File "C:\Program Files (x86)\ShadowBot\shadowbot-5.16.50\python\lib\contextlib.py", line 524, in __exit__

   raise exc_details[1]

 File "C:\Program Files (x86)\ShadowBot\shadowbot-5.16.50\python\lib\contextlib.py", line 509, in __exit__

   if cb(*exc_details):

 File "C:\Program Files (x86)\ShadowBot\shadowbot-5.16.50\python\lib\contextlib.py", line 384, in _exit_wrapper

   callback(*args, **kwds)

ValueError: I/O operation on closed file.


During handling of the above exception, another exception occurred:


Traceback (most recent call last):

 File "C:\Users\Administrator\AppData\Local\ShadowBot\users\65235345841459200\apps\53eb3f79-5e62-4bde-a55d-02a4225d3bff\xbot_robot\download_file.py", line 107, in main

   get_to_excel(unzip_file_path, os.path.join(download_file_folder, config_file_name),insert_headline,insert_data)

 File "C:\Users\Administrator\AppData\Local\ShadowBot\users\65235345841459200\apps\53eb3f79-5e62-4bde-a55d-02a4225d3bff\xbot_robot\download_file.py", line 82, in get_to_excel

   raise Exception("文件从csv转excel失败" + str(e))

Exception: 文件从csv转excel失败I/O operation on closed file.


During handling of the above exception, another exception occurred:


Traceback (most recent call last):

 File "C:\Program Files (x86)\ShadowBot\shadowbot-5.16.50\python\lib\runpy.py", line 193, in _run_module_as_main

   "__main__", mod_spec)

 File "C:\Program Files (x86)\ShadowBot\shadowbot-5.16.50\python\lib\runpy.py", line 85, in _run_code

   exec(code, run_globals)

 File "C:\Program Files (x86)\ShadowBot\shadowbot-5.16.50\python\lib\site-packages\xbot_interpreter.py", line 113, in <module>

   main()

 File "C:\Program Files (x86)\ShadowBot\shadowbot-5.16.50\python\lib\site-packages\xbot_interpreter.py", line 59, in main

   mod.main(args)

 File "C:\Users\Administrator\AppData\Local\ShadowBot\users\65235345841459200\apps\53eb3f79-5e62-4bde-a55d-02a4225d3bff\xbot_robot\process1.py", line 52, in main

   }, _block=("文件下载", 16, "调用模块"))

 File "<string>", line 92, in wrapper

 File "<string>", line 87, in wrapper

 File "<string>", line 37, in invoke_module

 File "C:\Users\Administrator\AppData\Local\ShadowBot\users\65235345841459200\apps\53eb3f79-5e62-4bde-a55d-02a4225d3bff\xbot_robot\download_file.py", line 112, in main

   raise Exception("文件转换失败,失败原因:", e)

Exception: ('文件转换失败,失败原因:', Exception('文件从csv转excel失败I/O operation on closed file.'))


收藏1
全部回答1
最新
发布回答
回答