root
ss
d60989a
#!/usr/bin/env python
"""
Dependency fixer for Resume Screener and Skill Extractor
This script ensures all dependencies are properly installed with compatible versions.
"""
import sys
import subprocess
import pkg_resources
import os
def install(package):
"""Install a package using pip"""
subprocess.check_call([sys.executable, "-m", "pip", "install", package])
def install_with_message(package, message=None):
"""Install a package with an optional message"""
if message:
print(f"\n{message}")
print(f"Installing {package}...")
install(package)
def main():
print("Running dependency fixer for Resume Screener and Skill Extractor...")
# Install core dependencies first
install_with_message("pip==23.1.2", "Upgrading pip to ensure compatibility")
install_with_message("setuptools==68.0.0", "Installing compatible setuptools")
# Check if we're in a Hugging Face Space
in_hf_space = os.environ.get("SPACE_ID") is not None
# Install key libraries with specific versions to ensure compatibility
dependencies = [
("streamlit==1.31.0", "Installing Streamlit for the web interface"),
("pdfplumber==0.10.1", "Installing PDF processing libraries"),
("PyPDF2==3.0.1", None),
("python-docx==1.0.1", None),
("rank-bm25==0.2.2", "Installing BM25 ranking library"),
("tqdm==4.66.1", "Installing progress bar utility"),
("faiss-cpu==1.7.4", "Installing FAISS for vector similarity search"),
("huggingface-hub==0.20.3", "Installing Hugging Face Hub"),
("transformers==4.36.2", "Installing Transformers"),
("sentence-transformers==2.2.2", "Installing Sentence Transformers"),
("torch==2.1.2", "Installing PyTorch"),
("nltk==3.8.1", "Installing NLTK for text processing"),
("pandas==2.1.3", "Installing data processing libraries"),
("numpy==1.24.3", None),
("plotly==5.18.0", "Installing visualization libraries"),
("spacy==3.7.2", "Installing spaCy for NLP"),
]
# Install all dependencies
for package, message in dependencies:
install_with_message(package, message)
# Download required NLTK data
print("\nDownloading NLTK data...")
install("nltk")
import nltk
nltk.download('punkt')
# Download spaCy model if not in a Hugging Face Space
# (Spaces should include this in the requirements.txt)
if not in_hf_space:
print("\nDownloading spaCy model...")
try:
subprocess.check_call([sys.executable, "-m", "spacy", "download", "en_core_web_sm"])
except:
install("https://github.com/explosion/spacy-models/releases/download/en_core_web_sm-3.7.0/en_core_web_sm-3.7.0.tar.gz")
print("\nDependency installation complete!")
print("You can now run the Resume Screener with: streamlit run app.py")
if __name__ == "__main__":
main()