Spaces:
Runtime error
Runtime error
Commit ·
d1dc22d
1
Parent(s): 71be0b6
Add application files
Browse files- DEPENDENCY_FIX.md +117 -0
- requirements.txt +3 -1
- requirements_gradio.txt +4 -3
DEPENDENCY_FIX.md
ADDED
|
@@ -0,0 +1,117 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Dependency Version Fix
|
| 2 |
+
|
| 3 |
+
## Issue
|
| 4 |
+
`ImportError: huggingface-hub>=0.19.3,<1.0 is required for a normal functioning of this module, but found huggingface-hub==1.1.4`
|
| 5 |
+
|
| 6 |
+
## Root Cause
|
| 7 |
+
Version conflict between `transformers` and `huggingface-hub`. The `transformers` 4.x series requires `huggingface-hub<1.0`.
|
| 8 |
+
|
| 9 |
+
## Solution
|
| 10 |
+
|
| 11 |
+
### Option 1: Fresh Install (Recommended)
|
| 12 |
+
|
| 13 |
+
```bash
|
| 14 |
+
# Remove existing packages
|
| 15 |
+
pip uninstall -y huggingface-hub transformers sentence-transformers
|
| 16 |
+
|
| 17 |
+
# Reinstall with correct versions
|
| 18 |
+
pip install -r requirements_gradio.txt
|
| 19 |
+
```
|
| 20 |
+
|
| 21 |
+
### Option 2: Force Correct Versions
|
| 22 |
+
|
| 23 |
+
```bash
|
| 24 |
+
# Install specific compatible versions
|
| 25 |
+
pip install "huggingface-hub>=0.19.3,<1.0" "transformers>=4.36.0,<5.0"
|
| 26 |
+
```
|
| 27 |
+
|
| 28 |
+
### Option 3: Use Virtual Environment (Best Practice)
|
| 29 |
+
|
| 30 |
+
```bash
|
| 31 |
+
# Create fresh environment
|
| 32 |
+
python -m venv venv
|
| 33 |
+
source venv/bin/activate # On Windows: venv\Scripts\activate
|
| 34 |
+
|
| 35 |
+
# Install all dependencies fresh
|
| 36 |
+
pip install -r requirements_gradio.txt
|
| 37 |
+
```
|
| 38 |
+
|
| 39 |
+
## Verification
|
| 40 |
+
|
| 41 |
+
After fixing, verify the installation:
|
| 42 |
+
|
| 43 |
+
```bash
|
| 44 |
+
python -c "import transformers; import huggingface_hub; print(f'transformers: {transformers.__version__}'); print(f'huggingface-hub: {huggingface_hub.__version__}')"
|
| 45 |
+
```
|
| 46 |
+
|
| 47 |
+
Expected output:
|
| 48 |
+
```
|
| 49 |
+
transformers: 4.36.x or higher (but <5.0)
|
| 50 |
+
huggingface-hub: 0.19.x - 0.99.x (but <1.0)
|
| 51 |
+
```
|
| 52 |
+
|
| 53 |
+
## For Hugging Face Spaces
|
| 54 |
+
|
| 55 |
+
The `requirements_gradio.txt` has been updated with correct version constraints:
|
| 56 |
+
|
| 57 |
+
```txt
|
| 58 |
+
huggingface-hub>=0.19.3,<1.0
|
| 59 |
+
transformers>=4.36.0,<5.0
|
| 60 |
+
```
|
| 61 |
+
|
| 62 |
+
When you push to HF Spaces, it will automatically use the correct versions.
|
| 63 |
+
|
| 64 |
+
## Why This Happened
|
| 65 |
+
|
| 66 |
+
The original `requirements_gradio.txt` had:
|
| 67 |
+
- `huggingface-hub==0.26.2` (pinned)
|
| 68 |
+
- `transformers==4.45.0` (pinned)
|
| 69 |
+
|
| 70 |
+
These are compatible, but if pip resolved dependencies differently or if there was a cached version, it might install `huggingface-hub>=1.0`, which breaks `transformers` 4.x.
|
| 71 |
+
|
| 72 |
+
## Fixed Version Constraints
|
| 73 |
+
|
| 74 |
+
Now using version ranges for better compatibility:
|
| 75 |
+
- `huggingface-hub>=0.19.3,<1.0` - Compatible with transformers 4.x
|
| 76 |
+
- `transformers>=4.36.0,<5.0` - Modern enough for features, <5.0 for compatibility
|
| 77 |
+
|
| 78 |
+
## Still Getting Errors?
|
| 79 |
+
|
| 80 |
+
### Error: "No module named 'transformers'"
|
| 81 |
+
```bash
|
| 82 |
+
pip install transformers
|
| 83 |
+
```
|
| 84 |
+
|
| 85 |
+
### Error: "No module named 'sentence_transformers'"
|
| 86 |
+
```bash
|
| 87 |
+
pip install sentence-transformers
|
| 88 |
+
```
|
| 89 |
+
|
| 90 |
+
### Error: Version conflict persists
|
| 91 |
+
```bash
|
| 92 |
+
# Nuclear option - remove all and reinstall
|
| 93 |
+
pip freeze | xargs pip uninstall -y
|
| 94 |
+
pip install -r requirements_gradio.txt
|
| 95 |
+
```
|
| 96 |
+
|
| 97 |
+
## Testing
|
| 98 |
+
|
| 99 |
+
After fixing, test the import:
|
| 100 |
+
|
| 101 |
+
```bash
|
| 102 |
+
python -c "from app.orchestrator import Orchestrator; print('✓ All imports successful')"
|
| 103 |
+
```
|
| 104 |
+
|
| 105 |
+
If successful, you'll see:
|
| 106 |
+
```
|
| 107 |
+
✓ All imports successful
|
| 108 |
+
```
|
| 109 |
+
|
| 110 |
+
## Running the App
|
| 111 |
+
|
| 112 |
+
```bash
|
| 113 |
+
# Start the Gradio app
|
| 114 |
+
python app.py
|
| 115 |
+
```
|
| 116 |
+
|
| 117 |
+
The app should now start without import errors!
|
requirements.txt
CHANGED
|
@@ -16,4 +16,6 @@ aiohttp==3.9.1
|
|
| 16 |
pandas==2.1.4
|
| 17 |
# NEW: Web search integration
|
| 18 |
duckduckgo-search==4.1.1
|
| 19 |
-
|
|
|
|
|
|
|
|
|
| 16 |
pandas==2.1.4
|
| 17 |
# NEW: Web search integration
|
| 18 |
duckduckgo-search==4.1.1
|
| 19 |
+
# HuggingFace dependencies (compatible versions)
|
| 20 |
+
huggingface-hub>=0.19.3,<1.0
|
| 21 |
+
transformers>=4.36.0,<5.0
|
requirements_gradio.txt
CHANGED
|
@@ -3,9 +3,10 @@
|
|
| 3 |
# Gradio Interface
|
| 4 |
gradio==5.5.0
|
| 5 |
|
| 6 |
-
# Hugging Face
|
| 7 |
-
huggingface-hub
|
| 8 |
-
|
|
|
|
| 9 |
|
| 10 |
# FastAPI (for backend components)
|
| 11 |
fastapi==0.109.0
|
|
|
|
| 3 |
# Gradio Interface
|
| 4 |
gradio==5.5.0
|
| 5 |
|
| 6 |
+
# Hugging Face (compatible versions)
|
| 7 |
+
# Note: transformers 4.x requires huggingface-hub<1.0
|
| 8 |
+
huggingface-hub>=0.19.3,<1.0
|
| 9 |
+
transformers>=4.36.0,<5.0
|
| 10 |
|
| 11 |
# FastAPI (for backend components)
|
| 12 |
fastapi==0.109.0
|