python - FileNotFoundError: [Errno 2] No such file or directory: 'C:\\Users\\Ziyuan\\Desktop\\python-leakage-detection\\the_simulation_of_pressure.xlsx'
问题描述
我想用 Panda 来读取 excel 文件。我导入了熊猫库:import panda as pd
,然后,我尝试使用熊猫读取excel文件:<code>pressure_simulation=pd.read_excel(r'C:\Users\Ziyuan\Desktop\python-leakage-detection\the_simulation_of_pressure.xlsx') 或pressure_simulation=pd.read_excel('the_simulation_of_pressure.xlsx')
,它总是返回如下所示的错误:
FileNotFoundError Traceback (most recent call last)
<ipython-input-7-786c357dee31> in <module>
----> 1 pressure_simulation=pd.read_excel(r'C:\Users\Ziyuan\Desktop\python-leakage-detection\the_simulation_of_pressure.xlsx')
2 pressure_simulation
~\Desktop\python-leakage-detection\env\lib\site-packages\pandas\util\_decorators.py in wrapper(*args, **kwargs)
297 )
298 warnings.warn(msg, FutureWarning, stacklevel=stacklevel)
--> 299 return func(*args, **kwargs)
300
301 return wrapper
~\Desktop\python-leakage-detection\env\lib\site-packages\pandas\io\excel\_base.py in read_excel(io, sheet_name, header, names, index_col, usecols, squeeze, dtype, engine, converters, true_values, false_values, skiprows, nrows, na_values, keep_default_na, na_filter, verbose, parse_dates, date_parser, thousands, comment, skipfooter, convert_float, mangle_dupe_cols, storage_options)
334 if not isinstance(io, ExcelFile):
335 should_close = True
--> 336 io = ExcelFile(io, storage_options=storage_options, engine=engine)
337 elif engine and engine != io.engine:
338 raise ValueError(
~\Desktop\python-leakage-detection\env\lib\site-packages\pandas\io\excel\_base.py in __init__(self, path_or_buffer, engine, storage_options)
1069 ext = "xls"
1070 else:
-> 1071 ext = inspect_excel_format(
1072 content=path_or_buffer, storage_options=storage_options
1073 )
~\Desktop\python-leakage-detection\env\lib\site-packages\pandas\io\excel\_base.py in inspect_excel_format(path, content, storage_options)
947 assert content_or_path is not None
948
--> 949 with get_handle(
950 content_or_path, "rb", storage_options=storage_options, is_text=False
951 ) as handle:
~\Desktop\python-leakage-detection\env\lib\site-packages\pandas\io\common.py in get_handle(path_or_buf, mode, encoding, compression, memory_map, is_text, errors, storage_options)
649 else:
650 # Binary mode
--> 651 handle = open(handle, ioargs.mode)
652 handles.append(handle)
653
FileNotFoundError: [Errno 2] No such file or directory: 'C:\\Users\\Ziyuan\\Desktop\\python-leakage-detection\\the_simulation_of_pressure.xlsx'
你能给我一些想法来解决这个问题吗?非常感谢!
解决方案
推荐阅读
- elasticsearch - 弹性搜索显示“START_OBJECT 的未知键”异常
- javascript - 如何重复 classList.add()
- java - 将变量传递给paintComponent方法
- c# - 通过在 Unity 中计算增量位置来压缩 Vector3 列表
- quarkus - 来自另一个 maven 模块的 Quarkus Qute 模板位置
- texas-instruments - 我需要做什么才能安装最新版本的 Python 应用程序?TI-84 Plus CE-T Python 版
- scala - json4s 抛出 NoClassDefFoundError: java/sql/Timestamp
- mql4 - 无论单击“是”还是“否”按钮,消息框都会关闭交易
- javascript - 从 generateDataKeyPairWithoutPlaintext() 获取字符串数据
- python - 关于 Python 简写的问题