AttributeError module pdfkit has no attribute from url

import pdfkit
pdfkit.from_file(‘test.html’, ‘out.pdf’)

This is my code, iam trying to convert a html page to pdf ,when i running this code shows errror

AttributeError: partially initialized module ‘pdfkit’ has no attribute ‘from_url’ (most likely due to a circular import)
How to solve these

Hello Vishnu,

What have you tried to do to debug this?

Please copy and paste the full traceback, starting with the line
“Traceback…”.

What version of Python are you running? On what OS?

Here is the full traceback,iam using python 3.9 and pip 21.1.3 and windows 10

“C:\Users\HP\PycharmProjects\sample Project\venv\Scripts\python.exe” “C:/Users/HP/PycharmProjects/sample Project/file_sample.py”
Traceback (most recent call last):
File “C:\Users\HP\PycharmProjects\sample Project\file_sample.py”, line 2, in
import pdfkit
File “C:\Users\HP\PycharmProjects\sample Project\venv\lib\site-packages\pdfkit_init_.py”, line 10, in
from .pdfkit import PDFKit
File “C:\Users\HP\PycharmProjects\sample Project\venv\lib\site-packages\pdfkit\pdfkit.py”, line 6, in
from .configuration import Configuration
File “C:\Users\HP\PycharmProjects\sample Project\venv\lib\site-packages\pdfkit\configuration.py”, line 2, in
pdfkit.from_url(‘http://spsonline.in’,out.pdf)
AttributeError: partially initialized module ‘pdfkit’ has no attribute ‘from_url’ (most likely due to a circular import)

Process finished with exit code 1

Your traceback points to a problem on the second line of the file configuration.py.

After downloading the files for pdfkit from PyPI, these are the first few lines I see in configuration.py:

# -*- coding: utf-8 -*-
import subprocess
import sys


class Configuration(object):
    def __init__(self, wkhtmltopdf='', meta_tag_prefix='pdfkit-'):
        self.meta_tag_prefix = meta_tag_prefix

As you can see, unlike what is mentioned in the traceback, line 2 of that file is definitely not

pdfkit.from_url(‘http://spsonline.in’,out.pdf)

That URL points to the site of a school in India. It looks like the version of pdfkit you have installed has been mangled by someone else.