Problem running a project with transformers
Author: jooray
Pull request: no

### System Info

I am trying to run a project that uses transformers (whisper), I get this error message:

```
ValueError: Unable to compare versions for numpy>=1.17: need=1.17 found=None. This is unusual. Consider reinstalling numpy.
```

I have tried:

```
pip3 install numpy
pip3 install -I transformers --no-cache-dir --force-reinstall
```

When I run the same python interpreter (pip3 and python3 are from the same interpreter) and import numpy, it is successful:

```
$ head -1 `which whisper`
#!/usr/local/opt/python@3.10/bin/python3.10
$ /usr/local/opt/python@3.10/bin/python3.10
Python 3.10.9 (main, Dec 15 2022, 18:25:35) [Clang 14.0.0 (clang-1400.0.29.202)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy
>>> import numpy.version as version
>>> version.version
'1.24.1'
```

I was trying to dig deeper and looked at transformers/utils/versions.py. I looked at 

```python
        got_ver = importlib_metadata.version(pkg)
```

And got_ver indeed returns None, even though I can use numpy:

```
Python 3.10.9 (main, Dec 15 2022, 18:25:35) [Clang 14.0.0 (clang-1400.0.29.202)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy
>>> import importlib.metadata as importlib_metadata
>>> numpy.version.version
'1.24.1'
>>> print(importlib_metadata.version("numpy"))
None
```


### Who can help?

_No response_

### Information

- [ ] The official example scripts
- [X] 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

```
Python 3.10.9 (main, Dec 15 2022, 18:25:35) [Clang 14.0.0 (clang-1400.0.29.202)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy
>>> import importlib.metadata as importlib_metadata
>>> numpy.version.version
'1.24.1'
>>> print(importlib_metadata.version("numpy"))
None
```

### Expected behavior

The last line would not return None and the transformer library would not return this:

```
>>> import transformers
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.10/site-packages/transformers/__init__.py", line 30, in <module>
    from . import dependency_versions_check
  File "/usr/local/lib/python3.10/site-packages/transformers/dependency_versions_check.py", line 41, in <module>
    require_version_core(deps[pkg])
  File "/usr/local/lib/python3.10/site-packages/transformers/utils/versions.py", line 123, in require_version_core
    return require_version(requirement, hint)
  File "/usr/local/lib/python3.10/site-packages/transformers/utils/versions.py", line 117, in require_version
    _compare_versions(op, got_ver, want_ver, requirement, pkg, hint)
  File "/usr/local/lib/python3.10/site-packages/transformers/utils/versions.py", line 45, in _compare_versions
    raise ValueError(
ValueError: Unable to compare versions for numpy>=1.17: need=1.17 found=None. This is unusual. Consider reinstalling numpy.
```


Comments:
I am unable to reproduce on my side, even in a new environment an installing numpy 1.24.1. Could you maybe try a full re-install in a fresh environment?

It is a system-wide Python install, I currently don't have time to reinstall the whole system.

I hot-fixed it by removing numpy from transformers/dependency_versions_check.py, I changed pkgs_to_check_at_runtime to not include numpy.

```python
pkgs_to_check_at_runtime = "python tqdm regex requests packaging filelock tokenizers".split()
```

After that, everything works (including, obviously, numpy), so it is really just the check that is broken.

Sharing for others who might stumble on the issue.

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.

I am having the same issue, and have reproduced the steps above.
Doing the hot-fix of removing Numpy from the dependency checks seems to have worked 👍 

Maybe check your `site-packages/` directory first? This issue has also happened to me because both `numpy-1.24.2.dist-info/` and `numpy-1.24.2-py3.10.egg-info/` exist in `site-packages/`, and `numpy-1.24.2-py3.10.egg-info/` is an empty directory. I assume this mainly when `importlib_metadata` happens to seek metadata in a different directory, and the directory relative happens to be empty, it might return `None`. You can try to check your directory by this

```
$ ls /opt/homebrew/lib/python3.10/site-packages/ | grep numpy
```

In addition, you may use `rm -rf` to delete the empty one or the distracting one.

> Maybe check your `site-packages/` directory first? This issue has also happened to me because both `numpy-1.24.2.dist-info/` and `numpy-1.24.2-py3.10.egg-info/` exist in `site-packages/`, and `numpy-1.24.2-py3.10.egg-info/` is an empty directory. I assume this mainly when `importlib_metadata` happens to seek metadata in a different directory, and the directory relative happens to be empty, it might return `None`. You can try to check your directory by this
> 
> ```
> $ ls /opt/homebrew/lib/python3.10/site-packages/ | grep numpy
> ```
> 
> In addition, you may use `rm -rf` to delete the empty one or the distracting one.

deleting empty numpy-1.26.2-py3.10.egg-xxx directory resolves this issue for my MacBook M1 and transformers(huggingface) 

> > Maybe check your `site-packages/` directory first? This issue has also happened to me because both `numpy-1.24.2.dist-info/` and `numpy-1.24.2-py3.10.egg-info/` exist in `site-packages/`, and `numpy-1.24.2-py3.10.egg-info/` is an empty directory. I assume this mainly when `importlib_metadata` happens to seek metadata in a different directory, and the directory relative happens to be empty, it might return `None`. You can try to check your directory by this
> > ```
> > $ ls /opt/homebrew/lib/python3.10/site-packages/ | grep numpy
> > ```
> > 
> > 
> >     
> >       
> >     
> > 
> >       
> >     
> > 
> >     
> >   
> > In addition, you may use `rm -rf` to delete the empty one or the distracting one.
> 
> deleting empty numpy-1.26.2-py3.10.egg-xxx directory resolves this issue for my MacBook M1 and transformers(huggingface)

This also solved my issue. Thanks 🙌🏽

I did it because I installed multiple versions of python in different locations, then reinstalled numpy in another location where python was called and it was fine