forked from marc-shade/Ollama-Workbench
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_pdfkit.py
More file actions
58 lines (51 loc) · 1.85 KB
/
test_pdfkit.py
File metadata and controls
58 lines (51 loc) · 1.85 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#!/usr/bin/env python3
"""
Test script to verify pdfkit import
"""
import sys
import subprocess
import importlib.util
print("Python version:", sys.version)
print("\n=== Testing pdfkit import ===")
# Try to import pdfkit
try:
import pdfkit
print("✅ Successfully imported pdfkit")
print("pdfkit version:", getattr(pdfkit, "__version__", "unknown"))
print("pdfkit path:", pdfkit.__file__)
# Check if wkhtmltopdf is installed (required by pdfkit)
try:
path = pdfkit.configuration().wkhtmltopdf
if path:
print(f"✅ wkhtmltopdf found at: {path}")
# Try to get version
try:
version_output = subprocess.check_output([path, '--version'], stderr=subprocess.STDOUT).decode('utf-8').strip()
print(f"wkhtmltopdf version: {version_output}")
except subprocess.CalledProcessError as e:
print(f"❌ Error getting wkhtmltopdf version: {e}")
else:
print("❌ wkhtmltopdf path not found in configuration")
except Exception as e:
print(f"❌ Error checking wkhtmltopdf: {e}")
except ImportError as e:
print("❌ Failed to import pdfkit:", e)
# Check what's installed with pip
print("\n=== Checking pip installation ===")
try:
result = subprocess.run(
[sys.executable, "-m", "pip", "show", "pdfkit"],
capture_output=True,
text=True,
check=False
)
if result.returncode == 0:
print("✅ pdfkit is installed via pip:")
for line in result.stdout.splitlines():
if line.startswith("Name:") or line.startswith("Version:") or line.startswith("Location:"):
print(" ", line)
else:
print("❌ pdfkit is NOT installed via pip")
except Exception as e:
print("Error checking pdfkit installation:", e)
print("\n=== Test complete ===")