一介书生423 发表于 2023-10-31 10:23:06

求助

import os
import glob
if 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)









代码提示错误的原因是啥
D:\PythonProject\pythonProject\Scripts\python.exe E:\qycache\xuexi\pythonProject\爬虫学习\process.py
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: No such file or directory: 'may.csv'

Process finished with exit code 1

isdkz 发表于 2023-10-31 10:23:16

代码提示错误的原因是找不到文件"may.csv"。根据报错信息,最后一行指示了错误的原因,即找不到指定的文件。请确保文件路径正确,并且文件存在于指定路径中。

Mike_python小 发表于 2023-10-31 10:23:23

问题描述:

在运行Python脚本时,出现了以下错误提示:


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: No such file or directory: 'may.csv'


错误原因:

1. 在加载NumPy库时,出现了警告,提示从.libs目录下加载了多个DLL(动态链接库)文件。
2. 执行Python脚本时,尝试读取一个名为'may.csv'的文件,但该文件不存在。

解决方案:

1. 关于NumPy库的问题,可以忽略。这只是一个警告而已,不会影响Python脚本的执行。
2. 确保'may.csv'文件的路径和文件名都正确,并且该文件确实存在于对应的目录中。

修改代码:


import os
import glob
import pandas as pd

if 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')


注意:以上代码仅是一个示例,实际使用时需要根据具体情况进行修改。

球一个最佳答案谢谢啦!这对我非常重要!{:10_254:}{:10_254:}{:10_254:}

一介书生423 发表于 2023-10-31 10:25:21

isdkz 发表于 2023-10-31 10:23
代码提示错误的原因是找不到文件"may.csv"。根据报错信息,最后一行指示了错误的原因,即找不到指定的文件 ...

都在桌面的同一个文件夹内

一介书生423 发表于 2023-10-31 10:48:55

Mike_python小 发表于 2023-10-31 10:23
问题描述:

在运行Python脚本时,出现了以下错误提示:

可否留个邮箱 发数据和代码帮忙修正下呀 大神
页: [1]
查看完整版本: 求助