# Trouble installing Longcat

**URL:** <https://discuss.huggingface.co/t/trouble-installing-longcat/170972>\
**Category:** Beginners\
**Created:** [November 30, 2025, 5:34am UTC](https://discuss.huggingface.co/t/trouble-installing-longcat/170972 "2025-11-30T05:34:15Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![onimuska](https://avatars.discourse-cdn.com/v4/letter/o/8797f3/32.png) [@onimuska](https://discuss.huggingface.co/u/onimuska)\
**Post date:** [November 30, 2025, 5:34am UTC](https://discuss.huggingface.co/t/trouble-installing-longcat/170972/1 "2025-11-30T05:34:15Z")

</div>

i am having a LOT of trouble with this install of longcat. i have solved a LOT of dependency issues on the instal, but i just can’t get this one. please help

Installing collected packages: mpmath, typing-extensions, sympy, pillow, numpy, networkx, MarkupSafe, fsspec, filelock, jinja2, torch, torchvision, torchaudio  
Successfully installed MarkupSafe-2.1.5 filelock-3.19.1 fsspec-2025.9.0 jinja2-3.1.6 mpmath-1.3.0 networkx-3.3 numpy-2.1.2 pillow-11.3.0 sympy-1.13.1 torch-2.6.0+cu124 torchaudio-2.6.0+cu124 torchvision-0.21.0+cu124 typing-extensions-4.15.0  
Collecting ninja  
Using cached ninja-1.13.0-py3-none-win\_amd64.whl.metadata (5.1 kB)  
Using cached ninja-1.13.0-py3-none-win\_amd64.whl (309 kB)  
Installing collected packages: ninja  
Successfully installed ninja-1.13.0  
Collecting psutil  
Using cached psutil-7.1.3-cp37-abi3-win\_amd64.whl.metadata (23 kB)  
Using cached psutil-7.1.3-cp37-abi3-win\_amd64.whl (247 kB)  
Installing collected packages: psutil  
Successfully installed psutil-7.1.3  
Collecting packaging  
Using cached packaging-25.0-py3-none-any.whl.metadata (3.3 kB)  
Using cached packaging-25.0-py3-none-any.whl (66 kB)  
Installing collected packages: packaging  
Successfully installed packaging-25.0  
Collecting flash\_attn==2.7.4.post1  
Using cached flash\_attn-2.7.4.post1.tar.gz (6.0 MB)  
Installing build dependencies … done  
Getting requirements to build wheel … error  
error: subprocess-exited-with-error

× Getting requirements to build wheel did not run successfully.  
│ exit code: 1  
╰─\> [17 lines of output]  
Traceback (most recent call last):  
File “C:\Users\Owner\anaconda3\envs\longcat-video\lib\site-packages\pip\_vendor\pyproject\_hooks\_in\_process\_in\_process.py”, line 389, in  
main()  
File “C:\Users\Owner\anaconda3\envs\longcat-video\lib\site-packages\pip\_vendor\pyproject\_hooks\_in\_process\_in\_process.py”, line 373, in main  
json\_out[“return\_val”] = hook(\*\*hook\_input[“kwargs”])  
File “C:\Users\Owner\anaconda3\envs\longcat-video\lib\site-packages\pip\_vendor\pyproject\_hooks\_in\_process\_in\_process.py”, line 143, in get\_requires\_for\_build\_wheel  
return hook(config\_settings)  
File “C:\Users\Owner\AppData\Local\Temp\pip-build-env-gqm7d9al\overlay\Lib\site-packages\setuptools\build\_meta.py”, line 331, in get\_requires\_for\_build\_wheel  
return self.\_get\_build\_requires(config\_settings, requirements=)  
File “C:\Users\Owner\AppData\Local\Temp\pip-build-env-gqm7d9al\overlay\Lib\site-packages\setuptools\build\_meta.py”, line 301, in \_get\_build\_requires  
self.run\_setup()  
File “C:\Users\Owner\AppData\Local\Temp\pip-build-env-gqm7d9al\overlay\Lib\site-packages\setuptools\build\_meta.py”, line 512, in run\_setup  
super().run\_setup(setup\_script=setup\_script)  
File “C:\Users\Owner\AppData\Local\Temp\pip-build-env-gqm7d9al\overlay\Lib\site-packages\setuptools\build\_meta.py”, line 317, in run\_setup  
exec(code, locals())  
File “”, line 22, in  
ModuleNotFoundError: No module named ‘torch’  
[end of output]

note: This error originates from a subprocess, and is likely not a problem with pip.  
ERROR: Failed to build ‘flash\_attn’ when getting requirements to build wheel  
Requirement already satisfied: torch==2.6.0 in c:\users\owner\anaconda3\envs\longcat-video\lib\site-packages (from -r requirements.txt (line 1)) (2.6.0+cu124)  
Collecting numpy==1.26.4 (from -r requirements.txt (line 2))  
Downloading numpy-1.26.4-cp310-cp310-win\_amd64.whl.metadata (61 kB)  
Collecting transformers==4.41.0 (from -r requirements.txt (line 3))  
Using cached transformers-4.41.0-py3-none-any.whl.metadata (43 kB)  
Collecting loguru==0.7.2 (from -r requirements.txt (line 4))  
Using cached loguru-0.7.2-py3-none-any.whl.metadata (23 kB)  
Collecting diffusers==0.35.1 (from -r requirements.txt (line 5))  
Using cached diffusers-0.35.1-py3-none-any.whl.metadata (20 kB)  
Collecting einops==0.8.0 (from -r requirements.txt (line 6))  
Using cached einops-0.8.0-py3-none-any.whl.metadata (12 kB)  
Collecting ftfy==6.2.0 (from -r requirements.txt (line 7))  
Using cached ftfy-6.2.0-py3-none-any.whl.metadata (7.3 kB)  
Collecting psutil==6.0.0 (from -r requirements.txt (line 8))  
Using cached psutil-6.0.0-cp37-abi3-win\_amd64.whl.metadata (22 kB)  
Collecting av==12.0.0 (from -r requirements.txt (line 9))  
Downloading av-12.0.0-cp310-cp310-win\_amd64.whl.metadata (4.8 kB)  
Collecting opencv-python==4.9.0.80 (from -r requirements.txt (line 10))  
Using cached opencv\_python-4.9.0.80-cp37-abi3-win\_amd64.whl.metadata (20 kB)  
Collecting flash-attn==2.7.4.post1 (from -r requirements.txt (line 11))  
Using cached flash\_attn-2.7.4.post1.tar.gz (6.0 MB)  
Installing build dependencies … done  
Getting requirements to build wheel … error  
error: subprocess-exited-with-error

× Getting requirements to build wheel did not run successfully.  
│ exit code: 1  
╰─\> [17 lines of output]  
Traceback (most recent call last):  
File “C:\Users\Owner\anaconda3\envs\longcat-video\lib\site-packages\pip\_vendor\pyproject\_hooks\_in\_process\_in\_process.py”, line 389, in  
main()  
File “C:\Users\Owner\anaconda3\envs\longcat-video\lib\site-packages\pip\_vendor\pyproject\_hooks\_in\_process\_in\_process.py”, line 373, in main  
json\_out[“return\_val”] = hook(\*\*hook\_input[“kwargs”])  
File “C:\Users\Owner\anaconda3\envs\longcat-video\lib\site-packages\pip\_vendor\pyproject\_hooks\_in\_process\_in\_process.py”, line 143, in get\_requires\_for\_build\_wheel  
return hook(config\_settings)  
File “C:\Users\Owner\AppData\Local\Temp\pip-build-env-lkz3y\_x0\overlay\Lib\site-packages\setuptools\build\_meta.py”, line 331, in get\_requires\_for\_build\_wheel  
return self.\_get\_build\_requires(config\_settings, requirements=)  
File “C:\Users\Owner\AppData\Local\Temp\pip-build-env-lkz3y\_x0\overlay\Lib\site-packages\setuptools\build\_meta.py”, line 301, in \_get\_build\_requires  
self.run\_setup()  
File “C:\Users\Owner\AppData\Local\Temp\pip-build-env-lkz3y\_x0\overlay\Lib\site-packages\setuptools\build\_meta.py”, line 512, in run\_setup  
super().run\_setup(setup\_script=setup\_script)  
File “C:\Users\Owner\AppData\Local\Temp\pip-build-env-lkz3y\_x0\overlay\Lib\site-packages\setuptools\build\_meta.py”, line 317, in run\_setup  
exec(code, locals())  
File “”, line 22, in  
ModuleNotFoundError: No module named ‘torch’  
[end of output]

note: This error originates from a subprocess, and is likely not a problem with pip.  
ERROR: Failed to build ‘flash-attn’ when getting requirements to build wheel  
(longcat-video)

any advice would be greatly appreciated.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/hellohellohello/original/2X/d/de4155eb4aa4108ecb32a1389d7cc37ae69f88b7.png) [@system](https://discuss.huggingface.co/u/system)\
**Post date:** [November 30, 2025, 5:34am UTC](https://discuss.huggingface.co/t/trouble-installing-longcat/170972/2 "2025-11-30T05:34:16Z")

</div>



---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/hellohellohello/original/2X/d/de4155eb4aa4108ecb32a1389d7cc37ae69f88b7.png) [@system](https://discuss.huggingface.co/u/system)\
**Post date:** [November 30, 2025, 1:34pm UTC](https://discuss.huggingface.co/t/trouble-installing-longcat/170972/3 "2025-11-30T13:34:17Z")

</div>



---

<div class="post-metadata">

**Author:** ![John6666](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/john6666/32/27664_2.png) [@John6666](https://discuss.huggingface.co/u/John6666)\
**Post date:** [November 30, 2025, 2:18pm UTC](https://discuss.huggingface.co/t/trouble-installing-longcat/170972/4 "2025-11-30T14:18:23Z")

</div>

To explain it fully would take a while, but to put it simply, installing Flash Attention can be quite a challenge depending on your environment.

* * *

I’ll break this into:

1. What exactly your error means
2. The real causes (there are two)
3. Concrete solutions you can choose from (with commands)

* * *

## 1. What your error actually means

You already have Torch:

```plaintext
Successfully installed ... torch-2.6.0+cu124 torchaudio-2.6.0+cu124 torchvision-0.21.0+cu124

```

But when installing `flash_attn==2.7.4.post1` you get:

```plaintext
Installing build dependencies ... done
Getting requirements to build wheel ... error
...
ModuleNotFoundError: No module named 'torch'
ERROR: Failed to build 'flash_attn'

```

and again via `requirements.txt`:

```plaintext
Collecting flash-attn==2.7.4.post1 (from -r requirements.txt)
...
Getting requirements to build wheel ... error
ModuleNotFoundError: No module named 'torch'

```

Key points:

- Torch **is** installed in your Conda env.
- The error is thrown **inside a temporary build environment** that pip creates just for building `flash_attn`. That temporary env does **not** see your torch.
- This is a known, common problem with FlashAttention: PyPI’s page explicitly says that if you see `ModuleNotFoundError: No module named 'torch'`, it is “likely because of pypi’s installation isolation” and tells you to use `pip install flash-attn --no-build-isolation`. ([PyPI](https://pypi.org/project/flash-attn-wheels/ "flash-attn-wheels"))

On top of that, you are on **Windows** , and FlashAttention is a heavy CUDA/C++ extension that is mainly tested on Linux. A lot of people hit additional problems building it from source on Windows and solve it via prebuilt wheels or WSL2. ([GitHub](https://github.com/Dao-AILab/flash-attention/issues/1469 "[How-to]How to get Flash-Attention under windows 11 CUDA"))

So:

- Immediate cause: pip’s build isolation environment cannot import `torch`.
- Structural cause: FlashAttention is a compiled CUDA extension with weak native Windows support.

* * *

## 2. Background: what pip is doing and why Torch “disappears”

Modern pip uses **PEP 517 build isolation** for packages that declare a `pyproject.toml` (FlashAttention does).

When you run:

```bash
pip install flash_attn==2.7.4.post1

```

pip does roughly:

1. Reads `pyproject.toml`, sees a build backend (e.g. setuptools) and a list of build requirements.

2. Creates a **temporary virtual environment** in a temp directory (like your `pip-build-env-gqm7d9al`).

3. Installs only build-time dependencies there (setuptools, wheel, maybe CUDA/compilers).

4. Runs the build backend inside that isolated env to:

Inside this isolated build env:

- Your `torch==2.6.0+cu124` from `longcat-video` Conda env is **not installed**.

- FlashAttention’s setup code does `import torch` to:

Because `torch` is not installed in the isolated env, `import torch` fails →  
`ModuleNotFoundError: No module named 'torch'`.

This exact pattern shows up in multiple issues on the FlashAttention repo and Stack Overflow, with identical logs (`Installing build dependencies ... done`, `Getting requirements to build wheel ... error`, then `ModuleNotFoundError: No module named 'torch'`). ([GitHub](https://github.com/Dao-AILab/flash-attention/issues/309 "No module named 'torch'” while installing from pip · Issue ..."))

The FlashAttention maintainers solved it by telling people to **turn off build isolation** :

```bash
pip install flash-attn --no-build-isolation

```

which forces pip to build using your real environment, where Torch _is_ installed. ([PyPI](https://pypi.org/project/flash-attn-wheels/ "flash-attn-wheels"))

So the error message is misleading: Torch is installed, but not in the small private env pip uses for building.

* * *

## 3. Background: why FlashAttention is fussy, especially on Windows

FlashAttention is not a typical pure-Python library:

- It provides **custom fused CUDA kernels** for attention, tightly tied to:

- It is primarily developed and tested on **Linux** ; Windows support exists but is patchy and depends on custom wheels or manual builds. ([GitHub](https://github.com/Dao-AILab/flash-attention/issues/1469 "[How-to]How to get Flash-Attention under windows 11 CUDA"))

For Linux, the recommended path is:

- Use the right PyTorch+CUDA combination (you already have Torch 2.6.0+cu124).
- Install FlashAttention with `pip install flash-attn --no-build-isolation`. ([PyPI](https://pypi.org/project/flash-attn/ "flash-attn"))

For Windows:

- Many users report that building from source is slow and fragile (hours of compile time, Visual Studio / NVCC configuration, etc.). Guides suggest:

- Because of this, some people now publish **pre-built Windows wheels** just for FlashAttention:

So building from source on Windows is possible, but often not worth the headache compared to installing a matching wheel.

* * *

## 4. LongCat-Video’s specific requirements

The official LongCat-Video README says to do exactly what you did: ([GitHub](https://github.com/meituan-longcat/LongCat-Video "GitHub - meituan-longcat/LongCat-Video"))

```bash
# create conda environment
conda create -n longcat-video python=3.10
conda activate longcat-video

# install torch (configure according to your CUDA version)
pip install torch==2.6.0+cu124 torchvision==0.21.0+cu124 torchaudio==2.6.0 --index-url https://download.pytorch.org/whl/cu124

# install flash-attn-2
pip install ninja
pip install psutil
pip install packaging
pip install flash_attn==2.7.4.post1

# install other requirements
pip install -r requirements.txt

```

And then notes:

> FlashAttention-2 is enabled in the model config by default; you can also change the model config (`./weights/LongCat-Video/dit/config.json`) to use FlashAttention-3 or xformers once installed. ([GitHub](https://github.com/meituan-longcat/LongCat-Video "GitHub - meituan-longcat/LongCat-Video"))

So:

- Your versions (Python 3.10 + torch 2.6.0+cu124 + flash\_attn 2.7.4.post1) are **exactly** what LongCat expects.
- The only reason you fail is the packaging / platform story around `flash_attn` itself.

* * *

## 5. Concrete causes in your case

Let’s spell them out clearly and tie them directly to your logs.

### Cause A: pip build isolation hides Torch from FlashAttention

- Torch is installed in `C:\Users\Owner\anaconda3\envs\longcat-video\lib\site-packages`.
- Pip’s build env lives under `C:\Users\Owner\AppData\Local\Temp\pip-build-env-...`.
- FlashAttention’s setup is executed inside this temp env when pip runs `get_requires_for_build_wheel`. It tries `import torch` and fails because Torch is not installed there.
- Result: `ModuleNotFoundError: No module named 'torch'` and `Failed to build 'flash_attn'`.

Exactly this situation is documented in:

- FlashAttention’s PyPI page, with the warning and recommended `--no-build-isolation` fix. ([PyPI](https://pypi.org/project/flash-attn-wheels/ "flash-attn-wheels"))

- GitHub issues #309, #1920, etc., where users see identical logs and are told to either:

### Cause B: `flash_attn` has no ready-made wheel for your Windows platform by default

- On Windows, pip often cannot find a prebuilt wheel on PyPI for your exact combination (PyTorch 2.6.0 + CUDA 12.4 + Python 3.10 + flash\_attn 2.7.4.post1). It then tries to **build from source**.

- Building from source on Windows:

So even after you fix build isolation, you may still hit C++/CUDA build errors unless you either:

- install a **matching prebuilt wheel** , or
- move to Linux/WSL2 and follow the official instructions there, or
- skip FlashAttention entirely and change LongCat’s attention backend.

* * *

## 6. Solutions you can realistically choose from

There is no single “magic” fix; there are a few solid paths. I’ll list them from “least invasive” to “most robust”.

### Option 1 — Try the official fix: build in your real env (no isolation)

This directly addresses the `ModuleNotFoundError: No module named 'torch'`.

1. Activate your env:

2. Make sure basic build tools are up to date:

3. Install FlashAttention **without build isolation** :

4. If that succeeds, then:

What can still go wrong:

- On Windows, this may now progress past the “torch missing” phase and then fail with MSVC/NVCC errors, RAM issues, etc. Guides warn that building from source can take 1–3+ hours and is sensitive to toolchain setup. ([Reddit](https://www.reddit.com/r/Oobabooga/comments/1jq3uj9/guide_getting_flash_attention_2_working_on/ "[Guide] Getting Flash Attention 2 Working on Windows for ..."))

If your goal is to experiment quickly and not debug compilers, you may prefer Options 2 or 3 instead.

* * *

### Option 2 — Install a prebuilt FlashAttention wheel for your exact stack

This avoids compiling on Windows entirely.

There is a dedicated repo `mjun0812/flash-attention-prebuild-wheels` that publishes prebuilt wheels for **Linux and Windows**. The latest release (`v0.4.19`) explicitly lists Windows wheels for:

- FlashAttention: 2.7.4.post1, 2.8.3
- Python: 3.10, 3.11, 3.12, 3.13
- PyTorch: 2.5, 2.6, 2.7, 2.8, 2.9
- CUDA: 12.4, 12.6, 13.0 ([GitHub](https://github.com/mjun0812/flash-attention-prebuild-wheels "mjun0812/flash-attention-prebuild-wheels: Provide with pre ..."))

That perfectly matches:

- Python 3.10
- Torch 2.6.0+cu124
- CUDA 12.4
- FlashAttention 2.7.4.post1

Typical procedure:

1. Stay with your current env:

2. Visit the `v0.4.19` release page for `mjun0812/flash-attention-prebuild-wheels`. ([GitHub](https://github.com/mjun0812/flash-attention-prebuild-wheels "mjun0812/flash-attention-prebuild-wheels: Provide with pre ..."))

3. Download the `.whl` whose filename encodes:

4. Install it directly:

5. Verify:

6. Then:

This way, pip sees that `flash-attn==2.7.4.post1` is already installed and does not try to build it again.

Alternatives:

- Other Windows wheel sources mentioned online include:

Tradeoffs:

- You must ensure the wheel’s **Python** , **Torch** , and **CUDA** versions match your environment exactly. If they don’t, you’ll get import or runtime errors.
- You’re relying on community-built wheels rather than official PyPI wheels, but this is a common route people take to get FlashAttention working on Windows. ([GitHub](https://github.com/mjun0812/flash-attention-prebuild-wheels "mjun0812/flash-attention-prebuild-wheels: Provide with pre ..."))

* * *

### Option 3 — Skip FlashAttention entirely and use a different backend

LongCat-Video’s README explicitly says: ([GitHub](https://github.com/meituan-longcat/LongCat-Video "GitHub - meituan-longcat/LongCat-Video"))

> FlashAttention-2 is enabled in the model config by default; you can also change the model config (`./weights/LongCat-Video/dit/config.json`) to use FlashAttention-3 or xformers once installed.

And in practice you can also design it to fall back to **PyTorch’s native attention** (SDPA) if you are okay with slower generation.

Steps:

1. Edit `requirements.txt` in the LongCat repo and **comment out** the FlashAttention line:

2. Install everything else:

3. After you download the model weights (via `huggingface-cli` as in README), open:

4. Look for fields controlling attention backend (naming may vary, e.g. `attn_backend`, `use_flash_attn`). Change them so they do **not** expect FlashAttention:

5. Run the demos as usual:

Downsides:

- Generation will be slower, especially for long high-res videos, because you’re not using fused attention kernels.
- But for testing, experimentation, and medium-length videos, this is usually perfectly acceptable and significantly easier than wrestling with FlashAttention on Windows.

This is often the most pragmatic tradeoff: you get LongCat working now, and you can always revisit FlashAttention later.

* * *

### Option 4 — Use Linux or WSL2 and follow the README literally

LongCat-Video and FlashAttention are primarily tuned for **Linux + CUDA**. The README you’re following assumes that environment. ([GitHub](https://github.com/meituan-longcat/LongCat-Video "GitHub - meituan-longcat/LongCat-Video"))

A very robust approach is:

1. Use a Linux environment (bare metal or WSL2 with GPU passthrough).

2. Install CUDA 12.4 and the exact LongCat stack:

3. Optionally, use a preconfigured guide such as the DigitalOcean tutorial, which walks through setting up LongCat-Video on their GPU droplets with the right drivers/tooling. ([DigitalOcean](https://www.digitalocean.com/community/tutorials/longcat-video-sora-alternative "How to Run the best Sora 2 alternative Meituan LongCat ..."))

Pros:

- You’re running in the environment the authors and FlashAttention maintainers actually test.
- Fewer platform-specific surprises.

Cons:

- Requires either a dual-boot/WSL2 setup or a remote Linux machine.

* * *

## 7. Minor side notes about your environment

Not blockers now, but worth being aware of:

- You installed:

Pip will try to adjust these during `pip install -r requirements.txt`. This is usually fine, but mixing many manual installs with a strict `requirements.txt` can sometimes cause confusing version downgrades or binary-ABI mismatches (especially for numpy). Keeping a **clean environment** that only follows the README plus any deliberate change (like removing FlashAttention) reduces noise when you debug.

* * *

## 8. Short recap (causes and solutions)

**Causes**

- The `ModuleNotFoundError: No module named 'torch'` during `flash_attn` install is caused by **pip’s build isolation** : FlashAttention’s build runs inside a temporary env that doesn’t have Torch, so `import torch` fails, even though Torch is installed in your Conda env. ([PyPI](https://pypi.org/project/flash-attn-wheels/ "flash-attn-wheels"))
- On Windows, pip often needs to **compile** FlashAttention from source because there’s no official wheel for your exact Python/Torch/CUDA combination on PyPI, and that compilation is complex and fragile. ([GitHub](https://github.com/Dao-AILab/flash-attention/issues/1469 "[How-to]How to get Flash-Attention under windows 11 CUDA"))

**Solutions**

- **Option 1:** Try the official fix:  
`python -m pip install --no-build-isolation flash-attn==2.7.4.post1` in your `longcat-video` env (then `pip install -r requirements.txt`). This fixes the “torch not found” piece but may still hit Windows compilation issues. ([PyPI](https://pypi.org/project/flash-attn-wheels/ "flash-attn-wheels"))

- **Option 2:** Use a **prebuilt Windows wheel** for your exact stack from `mjun0812/flash-attention-prebuild-wheels` (FlashAttention 2.7.4.post1, Python 3.10, Torch 2.6, CUDA 12.4), install it via `pip install path\to\wheel.whl`, then run `pip install -r requirements.txt`. ([GitHub](https://github.com/mjun0812/flash-attention-prebuild-wheels "mjun0812/flash-attention-prebuild-wheels: Provide with pre ..."))

- **Option 3:** Skip FlashAttention entirely:

- **Option 4:** Run LongCat-Video in a **Linux/WSL2** environment (local or cloud) where the exact torch + FlashAttention combo is officially tested, following the README as-is. ([GitHub](https://github.com/meituan-longcat/LongCat-Video "GitHub - meituan-longcat/LongCat-Video"))
