问题描述:
在运行Python脚本时,出现了以下错误提示:
[/code]
D:\PythonProject\pythonProject\lib\site-packages\numpy\_distributor_init.py:30: UserWarning: loaded more than 1 DLL from .libs:
D:\PythonProject\pythonProject\lib\site-packages\numpy\.libs\libopenblas.EL2C6PLE4ZYW3ECEVIV3OXXGRN2NRFM2.gfortran-win_amd64.dll
D:\PythonProject\pythonProject\lib\site-packages\numpy\.libs\libopenblas64__v0.3.21-gcc_10_3_0.dll
warnings.warn("loaded more than 1 DLL from .libs:"
Traceback (most recent call last):
File "E:\qycache\xuexi\pythonProject\爬虫学习\process.py", line 46, in <module>
df1 = pd.read_csv('may.csv')
File "D:\PythonProject\pythonProject\lib\site-packages\pandas\io\parsers\readers.py", line 912, in read_csv
return _read(filepath_or_buffer, kwds)
File "D:\PythonProject\pythonProject\lib\site-packages\pandas\io\parsers\readers.py", line 577, in _read
parser = TextFileReader(filepath_or_buffer, **kwds)
File "D:\PythonProject\pythonProject\lib\site-packages\pandas\io\parsers\readers.py", line 1407, in __init__
self._engine = self._make_engine(f, self.engine)
File "D:\PythonProject\pythonProject\lib\site-packages\pandas\io\parsers\readers.py", line 1661, in _make_engine
self.handles = get_handle(
File "D:\PythonProject\pythonProject\lib\site-packages\pandas\io\common.py", line 859, in get_handle
handle = open(
FileNotFoundError: [Errno 2] No such file or directory: 'may.csv'
[/code]
错误原因:
1. 在加载NumPy库时,出现了警告,提示从.libs目录下加载了多个DLL(动态链接库)文件。
2. 执行Python脚本时,尝试读取一个名为'may.csv'的文件,但该文件不存在。
解决方案:
1. 关于NumPy库的问题,可以忽略。这只是一个警告而已,不会影响Python脚本的执行。
2. 确保'may.csv'文件的路径和文件名都正确,并且该文件确实存在于对应的目录中。
修改代码:import osimport globimport pandas as pdif os.name == 'nt': # convention for storing / loading the DLL from # numpy/.libs/, if present try: from ctypes import WinDLL basedir = os.path.dirname(__file__) except: pass else: libs_dir = os.path.abspath(os.path.join(basedir, '.libs')) DLL_filenames = [] if os.path.isdir(libs_dir): for filename in glob.glob(os.path.join(libs_dir, '*openblas*dll')): # NOTE: would it change behavior to load ALL # DLLs at this path vs. the name restriction? WinDLL(os.path.abspath(filename)) DLL_filenames.append(filename) if len(DLL_filenames) > 1: import warnings warnings.warn("loaded more than 1 DLL from .libs:" "\n%s" % "\n".join(DLL_filenames), stacklevel=1)# 读取'may.csv'文件df1 = pd.read_csv('may.csv')
注意:以上代码仅是一个示例,实际使用时需要根据具体情况进行修改。
球一个最佳答案谢谢啦!这对我非常重要! |