# ModuleNotFoundError: No module named 'transformers'

**URL:** </static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fmodulenotfounderror-no-module-named-transformers%2F11609%3E%5C
**Category:** 🤗Transformers\
**Created:** [November 11, 2021, 9:05pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fmodulenotfounderror-no-module-named-transformers%2F11609 "2021-11-11T21:05:23Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![mashedpotatotime](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/mashedpotatotime/32/3103_2.png) [@mashedpotatotime](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fmashedpotatotime)%5C
**Post date:** [November 11, 2021, 9:05pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fmodulenotfounderror-no-module-named-transformers%2F11609%2F1 "2021-11-11T21:05:23Z")

</div>

Hi! I’ve been having trouble getting `transformers` to work in Spaces.

When tested in my environment using `python -c "from transformers import pipeline; print(pipeline('sentiment-analysis')('we love you'))"`, the results show it’s been properly installed. When imported in Colab it works fine too, but whenever deployed to Spaces it always returns the same ModuleNotFound error. Full traceback message:

Traceback:

```auto
File "/home/user/.local/lib/python3.8/site-packages/streamlit/script_runner.py", line 354, in _run_script
    exec(code, module. __dict__ )File "/home/user/app/app.py", line 1, in <module>
    from transformers import pipeline

```

It’s a simple test app using `transformers` and `streamlit`, - both of which were reinstalled with pip after creating a new venv and reinstalling tensorflow and pytorch. I also tried cleaning, uninstalling, and reinstalling conda based on advice from another forum. No dice.

Currently using:

Python 3.9.4  
Tensorflow 2.7.0  
PyTorch 1.10.0  
Transformers 4.12.3  
Streamlit 1.2.0

Any help greatly appreciated! Thanks 🤗

---

<div class="post-metadata">

**Author:** ![NDugar](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/ndugar/32/40501_2.png) [@NDugar](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2FNDugar)%5C
**Post date:** [November 12, 2021, 6:41am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fmodulenotfounderror-no-module-named-transformers%2F11609%2F2 "2021-11-12T06:41:54Z")

</div>

it might be due to not having a requirements file. Here is an example of what your spaces app should have - [flax-community/image-captioning at main](https://huggingface.co/spaces/flax-community/image-captioning/tree/main) try adding the requirements as they till the environment what packages to load. Hope this helps.

---

<div class="post-metadata">

**Author:** ![mashedpotatotime](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/mashedpotatotime/32/3103_2.png) [@mashedpotatotime](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fmashedpotatotime)%5C
**Post date:** [November 19, 2021, 11:23pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fmodulenotfounderror-no-module-named-transformers%2F11609%2F3 "2021-11-19T23:23:39Z")

</div>

That worked perfectly. Thank you!

---

<div class="post-metadata">

**Author:** ![Alwaysboy](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/alwaysboy/32/52486_2.png) [@Alwaysboy](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2FAlwaysboy)%5C
**Post date:** [August 12, 2025, 1:40pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fmodulenotfounderror-no-module-named-transformers%2F11609%2F4 "2025-08-12T13:40:25Z")

</div>

Same issue and solved by this method, thanks!
