nunchaku
nunchaku copied to clipboard
cannot import name 'to_diffusers' from 'nunchaku.lora.flux'
me too
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:
-
Open a command prompt (or Powershell) in ComfyUI's folder.
-
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).
- 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.
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.
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 corenunchakulibrary. Please follow the installation instructions in our README to install the correct version of thenunchakulibrary. -
You installed
nunchakuusingpip install nunchaku, but this is the wrong package. Thenunchakuname 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
nunchakucorrectly, 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.exeTo install
nunchakuinto this environment, use the following format:"G:\ComfyUI\python\python.exe" -m pip install <your-wheel-file>.whlExample (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
nunchakuin your working directory. Python may mistakenly load from that local folder instead of the installed library. Also, make sure your plugin folder undercustom_nodesis namedComfyUI-nunchaku, notnunchaku.
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.