nunchaku icon indicating copy to clipboard operation
nunchaku copied to clipboard

cannot import name 'to_diffusers' from 'nunchaku.lora.flux'

Open LoserCoderLi opened this issue 8 months ago • 4 comments

Image

LoserCoderLi avatar Apr 07 '25 02:04 LoserCoderLi

me too

taiczhi avatar Apr 07 '25 08:04 taiczhi

If you are using Nunchaku in ComfyUI (it looks like you are), I had this issue when first installing on Windows (may not be the same issue for everyone, but hopefully helps someone). The issue was occurring for me because I had installed Nunchaku outside of ComfyUI's virtual environment (venv) because I didn't use the venv's version of pip. To solve it:

  1. Open a command prompt (or Powershell) in ComfyUI's folder.

  2. Type the following, depending on what you used:

IF USING POWERSHELL: ./.venv/Scripts/activate.ps1

IF USING COMMAND PROMPT: ./.venv/Scripts/activate.bat

These commands should activate ComfyUI's virtual environment (you'll see a change in the prompt on the lefthand side if it worked).

  1. This, alone, isn't enough to ensure you install Nunchaku inside the venv, though (AND this is where the installation instructions are missing detail). You need to specifically install it using the venv's version of pip, NOT your local version of pip, or it will not install to a location that ComfyUI can access. To do so, finally, type the following command:

./.venv/Scripts/pip3.exe install nunchaku

This should fix the issue. If not, let me know, there may be another dependency that Nunchaku needs that wasn't installed through the venv properly, might be able to direct you into how to do so.

Beowulfe222 avatar Apr 07 '25 18:04 Beowulfe222

I supposed you were using ComfyUI portable, and this issue was very likely because you installed Nunchaku on a different Python instead of the embedded Python. I will write a FAQ soon for the instructions to avoid this issue.

lmxyy avatar Apr 07 '25 18:04 lmxyy

This error usually indicates that nunchaku was not installed properly. Please check the following common causes:

  • You only installed the ComfyUI plugin (ComfyUI-nunchaku) but not the core nunchaku library. Please follow the installation instructions in our README to install the correct version of the nunchaku library.

  • You installed nunchaku using pip install nunchaku, but this is the wrong package. The nunchaku name on PyPI is already taken by an unrelated project. Please uninstall the incorrect package and follow our installation guide to install the correct version.

  • (MOST LIKELY) You installed nunchaku correctly, but into the wrong Python environment. If you're using the ComfyUI portable package, its Python interpreter is very likely not the system default. To identify the correct Python path, launch ComfyUI and check the several initial lines in the log. For example, you will find

    ** Python executable: G:\ComfyuI\python\python.exe
    

    To install nunchaku into this environment, use the following format:

    "G:\ComfyUI\python\python.exe" -m pip install <your-wheel-file>.whl
    

    Example (for Python 3.11 and torch 2.6):

    "G:\ComfyUI\python\python.exe" -m pip install https://github.com/mit-han-lab/nunchaku/releases/download/v0.2.0/nunchaku-0.2.0+torch2.6-cp311-cp311-linux_x86_64.whl
    
  • You have a folder named nunchaku in your working directory. Python may mistakenly load from that local folder instead of the installed library. Also, make sure your plugin folder under custom_nodes is named ComfyUI-nunchaku, not nunchaku.

lmxyy avatar Apr 08 '25 03:04 lmxyy

Hi, we have provided tutorial videos to help you install and use Nunchaku on Windows, available in both English and Chinese. You can also follow the corresponding step-by-step text guide at docs/setup_windows.md. If you run into issues, these resources are a good place to start.

lmxyy avatar Apr 26 '25 04:04 lmxyy