[Python] Error: module 'pandas' has no attribute 'read_pdf'

Discussão em 'Python' iniciado por Stack, Agosto 29, 2025.

  1. Stack

    Stack Membro Participativo

    When importing the read_pdf method from pandas using

    import pandas as pd


    as the example demonstrated

    It shows the following error message

    AttributeError: AttributeError: module 'pandas' has no attribute 'read_pdf'

    Environment

    python --version: python 3.8.8
    OS and it's version: ? windows 10
    Anaconda (version 1.7.2)


    I was trying to read files that are of type .pdf / .docx / .txt from a file system that is already there.
    ​

    Example code:

    import pandas as pd
    import os # Os moduel for Operating System opertions
    import mimetypes

    # To change the current working directory to a new directory we use
    # os.chdir("Directory path")
    os.chdir("C:\\Users\\adity\\Documents\\Parent")

    # To List the files and folders in the current working directory
    # Return the file in form of List
    fid = os.listdir() #filesInDirectory

    # To check whether child 1 2 3 exist or not
    def checkChild(d):
    if len(d) == 0:
    return False
    if 'Child1' in d and 'Child2' in d and 'Child3' in d:
    return True
    else:
    return False

    # dc1 Directory Child One; dof Dictionary File System
    # nof name of file , ext Extension

    if checkChild(fid) == True: # if folders are there than read respective files
    for folder in fid:
    fileDir = folder
    os.chdir(directory+f"\\{fileDir}") # Changing directory to respective child
    dc = os.listdir()[0] # dc contains the name of file with extension
    nof,ext = os.path.splitext(dc)
    if ext =='':
    ext = mimetypes.guess_extension(os.getcwd())

    if ext == '.pdf' and fileDir == 'Child1':
    child1Pdf = pd.read_pdf(f'{dc}') #**Error Line**




    Error Output:


    *AttributeError Traceback (most recent call last) in 9 print(dc) 10 if ext == '.pdf' and fileDir == 'Child1': ---> 11 child1Pdf = pd.read_pdf(f'{dc}') 12 13

    ~\anaconda3\lib\site-packages\pandas_init_.py in getattr(name) 242 return _SparseArray 243 --> 244 raise AttributeError(f"module 'pandas' has no attribute '{name}'") 245 246

    AttributeError: module 'pandas' has no attribute 'read_pdf'*
    ​

    I am not getting any solution for this error

    Continue reading...

Compartilhe esta Página