File size: 1,375 Bytes
78112f2
 
 
 
 
 
 
 
 
 
 
 
 
 
ad540bf
 
78112f2
 
 
 
ad540bf
78112f2
 
 
ad540bf
 
 
 
 
78112f2
 
 
 
 
 
 
 
 
 
 
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
import os
import sys
import subprocess

def setup_local_diffusers():
    # 1. Try to uninstall existing diffusers package
    try:
        subprocess.check_call([sys.executable, "-m", "pip", "uninstall", "diffusers", "-y"])
        print("Successfully uninstalled existing diffusers package")
    except subprocess.CalledProcessError:
        print("No existing diffusers package found to uninstall")

    # 2. Get the current directory and add it to PYTHONPATH
    current_dir = os.path.dirname(os.path.abspath(__file__))
    
    # Add the parent directory of diffusers to Python path
    if current_dir not in sys.path:
        sys.path.insert(0, current_dir)
        print(f"Added {current_dir} to PYTHONPATH")

    # 3. Verify the import works
    try:
        import diffusers
        print(f"Successfully imported diffusers from: {diffusers.__file__}")
        
        # Verify specific module exists
        from diffusers.loaders.single_file import FromOriginalModelMixin
        print("Successfully imported FromOriginalModelMixin")
        
        return True
    except ImportError as e:
        print(f"Failed to import diffusers: {e}")
        return False

if __name__ == "__main__":
    success = setup_local_diffusers()
    if success:
        print("Local diffusers setup completed successfully")
    else:
        print("Failed to setup local diffusers")