BUG:cannot import name 'is_nltk_available' from 'transformers.utils.import_utils'
Author: Oten-arch
Pull request: no

### System Info

- `transformers` version: 4.21.0
- Platform: Linux-3.10.0-1160.105.1.el7.x86_64-x86_64-with-glibc2.17
- Python version: 3.10.13
- Huggingface_hub version: 0.21.4
- PyTorch version (GPU?): 2.0.1+cu117 (True)
- Tensorflow version (GPU?): not installed (NA)
- Flax version (CPU?/GPU?/TPU?): not installed (NA)
- Jax version: not installed
- JaxLib version: not installed
- Using GPU in script?: <fill in>
- Using distributed or parallel set-up in script?: <fill in>

### Who can help?

_No response_

### Information

- [ ] The official example scripts
- [ ] My own modified scripts

### Tasks

- [ ] An officially supported task in the `examples` folder (such as GLUE/SQuAD, ...)
- [ ] My own task or dataset (give details below)

### Reproduction

Traceback (most recent call last):
  File "/home/wjh/anaconda3/envs/dbgpt_env/lib/python3.10/site-packages/langchain_community/embeddings/huggingface.py", line 59, in __init__
    import sentence_transformers
  File "/home/wjh/anaconda3/envs/dbgpt_env/lib/python3.10/site-packages/sentence_transformers/__init__.py", line 3, in <module>
    from .datasets import SentencesDataset, ParallelSentencesDataset
  File "/home/wjh/anaconda3/envs/dbgpt_env/lib/python3.10/site-packages/sentence_transformers/datasets/__init__.py", line 1, in <module>
    from .DenoisingAutoEncoderDataset import DenoisingAutoEncoderDataset
  File "/home/wjh/anaconda3/envs/dbgpt_env/lib/python3.10/site-packages/sentence_transformers/datasets/DenoisingAutoEncoderDataset.py", line 5, in <module>
    from transformers.utils.import_utils import is_nltk_available, NLTK_IMPORT_ERROR
ImportError: cannot import name 'is_nltk_available' from 'transformers.utils.import_utils' (/home/wjh/anaconda3/envs/dbgpt_env/lib/python3.10/site-packages/transformers/utils/import_utils.py)

### Expected behavior

我希望不报错

Comments:
Hi @Oten-arch, thanks for raising this issue! 

4.21 is quite an old version of transformers. I'd suggest updating to the latest stable release: `pip install -U transformers`

Used the development and latest version of `transformers` library, still not working out for me either.

![image](https://github.com/huggingface/transformers/assets/73326807/c4d7976c-ca3e-42a5-b053-cc6fa26b08c1)
Getting this in my virtualenv and inside my actual Python folders.

It looks like there's an issue with either the environment or the installed package. I'm unable to replicate either of these issues and can successfully run the following 

```py
In [1]: from transformers.utils.import_utils import is_nltk_available

In [2]: from transformers import AutoTokenizer, AutoModelForTokenClassification
```

Therefore, there isn't really anything we can do on our side

I think the Python interpreter is getting confused on the transformers package straight up on my computer and the transformers package in the virtual environment. I see different paths either referencing the one in my AppData folder and my virtual environment for errors.

Yep, was the issue as the venv didn't have the binary I was constantly referencing (`python3.11`). I managed to get it working now.

@JustAnEric Hey how did you resolve it


`pip install transformers==4.36.0` solves this issue

Got that running, my app was taking the python transformers pkg which is outside the env by default while importing it, have upgraded that pkg outside the env.

@HourunLi Thank you, your fix worked for me

@Kota-11711406 that was my problem, sorry if it didn't make sense before! 😄 

Closing as the issue has been resolved 

> `pip install transformers==4.36.0` solves this issue

use this, will cause an error ：AttributeError: 'ChatGLMTokenizer' object has no attribute 'sp_tokenizer'. Did you mean: '_tokenize'?

@xhyyds Hi, have you ever solved this? I encountered the same situation.

> @xhyyds Hi, have you ever solved this? I encountered the same situation.

@chinak Are you at the latest version of `transformers`?

Delete the installed transformers and sentence-transformers,

I solved the problem by installing transformers first and then installing sentence-transformers.

For installation instructions, refer to the huggingface installation guide and Sbert.net installation guide.

conda install conda-forge::transformers
conda install -c conda-forge sentence-transformers