pandas读取并写入excel过程当中出现ValueError: source code string cannot contain null bytes

pandas读取并写入excel过程当中出现ValueError: source code string cannot contain null bytes

设备:macbookpro
系统:10.14.5
python小白,使用anaconda中spder导入pandas写入excel出现异常,说源代码字符串中不能包含空字符,检查了代码,没有发现代码中出现空字符,纠结了近两天,希望能有大神帮忙看一下。

import pandas as pd
import sys
input_file = sys.argv[1]
output_file = sys.argv[2]
data_frame = pd.read_excel(input_file, sheet_name='january_2013')
writer = pd.ExcelWriter(output_file)
data_frame.to_excel(writer, sheet_name='jan_13_output', index=False)
writer.save()

pandas读取并写入excel过程当中出现ValueError: source code string cannot contain null bytes_第1张图片

Traceback (most recent call last):
  File "./b_excel.py", line 14, in 
    writer = pd.ExcelWriter(output_file)
  File "/anaconda3/lib/python3.7/site-packages/pandas/io/excel/_base.py", line 632, in __new__
    engine = _get_default_writer(ext)
  File "/anaconda3/lib/python3.7/site-packages/pandas/io/excel/_util.py", line 42, in _get_default_writer
    "xlsxwriter", raise_on_missing=False, on_version="warn"
  File "/anaconda3/lib/python3.7/site-packages/pandas/compat/_optional.py", line 90, in import_optional_dependency
    module = importlib.import_module(name)
  File "/anaconda3/lib/python3.7/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "", line 1006, in _gcd_import
  File "", line 983, in _find_and_load
  File "", line 967, in _find_and_load_unlocked
  File "", line 677, in _load_unlocked
  File "", line 724, in exec_module
  File "", line 860, in get_code
  File "", line 791, in source_to_code
  File "", line 219, in _call_with_frames_removed
ValueError: source code string cannot contain null bytes

pandas读取并写入excel过程当中出现ValueError: source code string cannot contain null bytes_第2张图片

更新
把anaconda卸了重装就好了

你可能感兴趣的:(python,pandas,anaconda)