sd-webui-roop icon indicating copy to clipboard operation
sd-webui-roop copied to clipboard

ModuleNotFoundError: No module named 'launch' 求求了

Open tan6458 opened this issue 1 year ago • 3 comments

PS D:\Code\Python\sd-webui-roop-main> & C:/Users/Administrator/AppData/Local/Programs/Python/Python38/python.exe d:/Code/Python/sd-webui-roop-main/install.py Traceback (most recent call last): File "d:/Code/Python/sd-webui-roop-main/install.py", line 1, in import launch ModuleNotFoundError: No module named 'launch'

tan6458 avatar Sep 28 '23 15:09 tan6458

Replace the contents of install.py with the following and run python install.py again. The script below replaces the dependency on the launch module with the native subprocess to install the project dependencies.

import os
import subprocess  
import sys
from tqdm import tqdm
import urllib.request

req_file = os.path.join(os.path.dirname(os.path.realpath(__file__)), "requirements.txt")

models_dir = os.path.abspath("models/roop")
model_url = "https://github.com/dream80/roop_colab/releases/download/v0.0.1/inswapper_128.onnx"
model_name = os.path.basename(model_url)
model_path = os.path.join(models_dir, model_name)

def download(url, path):
    request = urllib.request.urlopen(url)
    total = int(request.headers.get('Content-Length', 0))
    with tqdm(total=total, desc='Downloading', unit='B', unit_scale=True, unit_divisor=1024) as progress:
        urllib.request.urlretrieve(url, path, reporthook=lambda count, block_size, total_size: progress.update(block_size))

if not os.path.exists(models_dir):
    os.makedirs(models_dir)

if not os.path.exists(model_path):
    download(model_url, model_path)

try:
    subprocess.run(["pip", "install", "-r", req_file], check=True)
except subprocess.CalledProcessError as e:
    print(f"Failed to install requirements: {e.stderr.decode('utf-8')}")
    sys.exit(1)

Ryan-Haines avatar Oct 17 '23 22:10 Ryan-Haines

I encountered an issue while running the install.py The script failed with a FileNotFoundError

Traceback (most recent call last):
File "C:\PYTHON\auto1111\stable-diffusion-webui\extensions\sd-webui-roop\install.py", line 27, in
subprocess.run(["pip", "install", "-r", req_file], check=True)
File "C:\Users\Me\AppData\Local\Programs\Python\Python310\lib\subprocess.py", line 503, in run
with Popen(*popenargs, **kwargs) as process:
File "C:\Users\Me\AppData\Local\Programs\Python\Python310\lib\subprocess.py", line 971, in init
self._execute_child(args, executable, preexec_fn, close_fds,
File "C:\Users\Me\AppData\Local\Programs\Python\Python310\lib\subprocess.py", line 1440, in _execute_child
hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
FileNotFoundError: [WinError 2] The system cannot find the file specified

I managed to resolve this by modifying the subprocess.

subprocess.run([sys.executable, "-m", "pip", "install", "-r", req_file], check=True)

JacobTheJacobs avatar Jan 12 '24 01:01 JacobTheJacobs

pip install --upgrade setuptools

solved my problem

hypiuser avatar Jan 19 '24 21:01 hypiuser