I couldn't import Trainer from transformers until I uninstalled datasets.
Author: OneGneralf
Pull request: no
Labels: name: bug

### System Info

transformers: 4.46.3
torch: 2.10.0+cu126
Python: 3.10.11 | packaged by Anaconda, Inc. | (main, May 16 2023, 00:55:32) [MSC v.1916 64 bit (AMD64)]
OS: Windows-10-10.0.26200-SP0
datasets: 4.8.5
VS Code: 1.118.1 (system setup)
### Who can help?

@SunMarc 

### Information

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

### Tasks

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

### Reproduction

```python
try:
    from transformers import Trainer
except Exception as e:
    print(e)
print("ok")
```


### Expected behavior

If Trainer is imported successfully, the terminal should  print "ok".

Comments:
Hi, I tried to reproduce this with the exact versions you mentioned (`transformers==4.46.3`, `datasets==4.8.5`) and the import works fine on my end.

Could you share the full traceback? Your reproduction script uses `except Exception as e: print(e)` which only prints the error message — a full stack trace would help narrow this down.

Also, I suspect `torch==2.10.0+cu126` might be the actual culprit here — that looks like a pre-release/nightly build. Could you try with a stable torch release (e.g. `2.5.1`) and see if the issue persists even without uninstalling `datasets`?

> Hi, I tried to reproduce this with the exact versions you mentioned (`transformers==4.46.3`, `datasets==4.8.5`) and the import works fine on my end.
> 
> Could you share the full traceback? Your reproduction script uses `except Exception as e: print(e)` which only prints the error message — a full stack trace would help narrow this down.
> 
> Also, I suspect `torch==2.10.0+cu126` might be the actual culprit here — that looks like a pre-release/nightly build. Could you try with a stable torch release (e.g. `2.5.1`) and see if the issue persists even without uninstalling `datasets`?

Thanks for your reply. I found it didn't work in VS Code, but it worked well in PyCharm. VS Code's version is 1.118.1(system setup); PyCharm's is 2025.3.1. 

> > Hi, I tried to reproduce this with the exact versions you mentioned (`transformers==4.46.3`, `datasets==4.8.5`) and the import works fine on my end.
> > Could you share the full traceback? Your reproduction script uses `except Exception as e: print(e)` which only prints the error message — a full stack trace would help narrow this down.
> > Also, I suspect `torch==2.10.0+cu126` might be the actual culprit here — that looks like a pre-release/nightly build. Could you try with a stable torch release (e.g. `2.5.1`) and see if the issue persists even without uninstalling `datasets`?
> 
> Thanks for your reply. I found it didn't work in VS Code, but it worked well in PyCharm. VS Code's version is 1.118.1(system setup); PyCharm's is 2025.3.1.

And in VS Code, it didn't output anything — as if it were printing an empty string.
```python
import traceback

try:
    from transformers import Trainer
except Exception:
    traceback.print_exc()  

print("ok")
``` 

<img width="404" height="46" alt="Image" src="https://github.com/user-attachments/assets/7df9844a-4610-4088-9b7e-8b0f2b91b5e1" />

@OneGneralf Thanks for the update — this narrows it down significantly.

VS Code printing nothing (not even an error) while PyCharm works fine points to a **Python interpreter mismatch**, not a `transformers` bug.

VS Code likely picked a different environment (e.g., base Anaconda) where `transformers` either isn't installed or has a version conflict that silently suppresses output.

**Quick check:**
- In VS Code: bottom-left corner (or `Ctrl+Shift+P` → "Python: Select Interpreter") — note the Python path
- In PyCharm: Settings → Project → Python Interpreter — note the Python path

Are they the same? If not, point VS Code to the same interpreter PyCharm uses.

**Also run this in VS Code's terminal to confirm:**
```python
import sys
print(sys.executable)
import transformers
print(transformers.__version__)
```

If the paths differ or this fails, switch VS Code to the correct interpreter and the issue should resolve.

> [@OneGneralf](https://github.com/OneGneralf) Thanks for the update — this narrows it down significantly.
> 
> VS Code printing nothing (not even an error) while PyCharm works fine points to a **Python interpreter mismatch**, not a `transformers` bug.
> 
> VS Code likely picked a different environment (e.g., base Anaconda) where `transformers` either isn't installed or has a version conflict that silently suppresses output.
> 
> **Quick check:**
> 
> * In VS Code: bottom-left corner (or `Ctrl+Shift+P` → "Python: Select Interpreter") — note the Python path
> * In PyCharm: Settings → Project → Python Interpreter — note the Python path
> 
> Are they the same? If not, point VS Code to the same interpreter PyCharm uses.
> 
> **Also run this in VS Code's terminal to confirm:**
> 
> import sys
> print(sys.executable)
> import transformers
> print(transformers.__version__)
> If the paths differ or this fails, switch VS Code to the correct interpreter and the issue should resolve.

Thanks for the detailed suggestions. I checked — `sys.executable` returns the same path in both IDEs.

This issue has been automatically marked as stale because it has not had recent activity. If you think this still needs to be addressed please comment on this thread.

Please note that issues that do not follow the [contributing guidelines](https://github.com/huggingface/transformers/blob/main/CONTRIBUTING.md) are likely to be ignored.