| # Configuration for fixing numpy._core import issue | |
| import os | |
| import sys | |
| def fix_numpy_import(): | |
| """Fix numpy._core import issue for Hugging Face Spaces""" | |
| try: | |
| # Force reinstall numpy with compatible version | |
| os.system("pip uninstall numpy -y") | |
| os.system("pip install numpy==1.26.4") | |
| # Force reload numpy | |
| if 'numpy' in sys.modules: | |
| del sys.modules['numpy'] | |
| import numpy as np | |
| print(f"✅ Numpy fixed and loaded successfully: {np.__version__}") | |
| return True | |
| except Exception as e: | |
| print(f"❌ Failed to fix numpy: {e}") | |
| return False | |
| if __name__ == "__main__": | |
| fix_numpy_import() | |