Unable to import transformers: ImportError: numpy>=1.17 is required for a normal functioning of this module, but found numpy==1.16.3
I'd installed transformers via `pip install transformers`

And made sure my python packages is up-to-date, however when I import transformers it shows the error message:

```
ImportError: numpy>=1.17 is required for a normal functioning of this module, but found numpy==1.16.3.
Try: pip install transformers -U or pip install -e '.[dev]' if you're working with git master
```

I'd made sure my numpy is version 1.20.1, and I'd tried as suggested in the message: `pip install transformers -U`

But it doesn't work. Please help me how could I import the package, thank you!
What is your working environment? Is it a Colab notebook, a Linux machine?<|||||>I'm working on my PC with Windows 10 system.

> What is your working environment? Is it a Colab notebook, a Linux machine?

<|||||>Probably your environments have different versions as @LysandreJik mentioned. Can you run the following command **where you get the error message (your working environment)**, and assure you have the correct numpy version.

    pip freeze | findstr "numpy"

You may try the following, but without locating your correct environment these probably do not help much.

    pip install -I transformers --no-cache-dir --force-reinstall<|||||>> pip freeze | findstr "numpy"

Hello! I'd followed your work, and it returns this:

![image](https://user-images.githubusercontent.com/19323465/118766646-47e66080-b8af-11eb-974b-1b343d9e3b36.png)

Why does this happen?<|||||>> Probably your environments have different versions as @LysandreJik mentioned. Can you run the following command **where you get the error message (your working environment)**, and assure you have the correct numpy version.
> 
> ```
> pip freeze | findstr "numpy"
> ```
> 
> You may try the following, but without locating your correct environment these probably do not help much.
> 
> ```
> pip install -I transformers --no-cache-dir --force-reinstall
> ```

Your second instruction works! It seems force-install may install all dependencies for transformer, but I still don't know why it couldn't run with the default numpy = 1.20.0

Thank you for your help!<|||||>Glad it solved your problem. We can close this issue then @laurence-lin.<|||||>> Glad it solved your problem. We can close this issue then @laurence-lin.

OK, thank you!<|||||>ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.
daal4py 2021.5.0 requires daal==2021.4.0, which is not installed.
conda-repo-cli 1.0.4 requires pathlib, which is not installed.
anaconda-project 0.10.2 requires ruamel-yaml, which is not installed.
mxnet 1.7.0.post2 requires numpy<1.17.0,>=1.8.2, but you have numpy 1.22.4 which is incompatible.
mxnet 1.7.0.post2 requires requests<2.19.0,>=2.18.4, but you have requests 2.28.0 which is incompatible.
numba 0.55.1 requires numpy<1.22,>=1.18, but you have numpy 1.22.4 which is incompatible.
jupyter-server 1.13.5 requires pywinpty<2; os_name == "nt", but you have pywinpty 2.0.2 which is incompatible.
d2l 0.17.5 requires matplotlib==3.5.1, but you have matplotlib 3.5.2 which is incompatible.
d2l 0.17.5 requires numpy==1.21.5, but you have numpy 1.22.4 which is incompatible.
d2l 0.17.5 requires requests==2.25.1, but you have requests 2.28.0 which is incompatible. 


pls help me out<|||||>I have the same issue but with `fastai`. Check out my [Git Issue](https://github.com/fastai/fastai/issues/3708).<|||||>> ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts. daal4py 2021.5.0 requires daal==2021.4.0, which is not installed. conda-repo-cli 1.0.4 requires pathlib, which is not installed. anaconda-project 0.10.2 requires ruamel-yaml, which is not installed. mxnet 1.7.0.post2 requires numpy<1.17.0,>=1.8.2, but you have numpy 1.22.4 which is incompatible. mxnet 1.7.0.post2 requires requests<2.19.0,>=2.18.4, but you have requests 2.28.0 which is incompatible. numba 0.55.1 requires numpy<1.22,>=1.18, but you have numpy 1.22.4 which is incompatible. jupyter-server 1.13.5 requires pywinpty<2; os_name == "nt", but you have pywinpty 2.0.2 which is incompatible. d2l 0.17.5 requires matplotlib==3.5.1, but you have matplotlib 3.5.2 which is incompatible. d2l 0.17.5 requires numpy==1.21.5, but you have numpy 1.22.4 which is incompatible. d2l 0.17.5 requires requests==2.25.1, but you have requests 2.28.0 which is incompatible.
> 
> pls help me out

I solved it this way:
`pip install -I transformers --no-cache-dir --force-reinstall`, as suggested by @devrimcavusoglu 
The this error appeared:
`ImportError: Something is wrong with the numpy installation. While importing we detected an older version of numpy in [.../.../...']. One method of fixing this is to repeatedly uninstall numpy until none is found, then reinstall this version.`
I did `sudo pip3 uninstall numpy` twice, until no numpy version was found, and then it worked. Tbh I have no idea why, but as long as it's working it is fine.

Hope this helps<|||||>find the old version numpy ， and delete the old version numpy by youself。<|||||>@devrimcavusoglu  I'am facing with the same issue, but the following command does not help: `pip install -I transformers --no-cache-dir --force-reinstall`.

I am on ubuntu, using a conda env named `py36`, and make sure I was operating in the correct env (as the `(py36)` line in the following logs).




```
(py36)                                                                                                                                                                                                                                                            
cyx@c9 ~                                                                                                                                                                                                                                                          
  % pip install -I transformers --no-cache-dir --force-reinstall       
xxxxxxx      downloading logs xxxxxxxxxxx                                                                                                                                                                                    
   Installing collected packages: zipp, typing-extensions, urllib3, pyparsing, importlib-resources, importlib-metadata, idna, charset-normalizer, certifi, tqdm, six, requests, regex, pyyaml, packaging, joblib, filelock, click, tokenizers, sacremoses, numpy, hug gingface-hub, dataclasses, transformers
ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.
allennlp 1.0.0 requires jsonnet>=0.10.0; sys_platform != "win32", which is not installed. allennlp 1.0.0 requires jsonpickle, which is not installed.
allennlp 1.0.0 requires tensorboardX>=1.2, which is not installed. bminf test requires cupy-cuda9<10,>=9, which is not installed.
torchvision 0.10.0 requires torch==1.9.0, but you have torch 1.10.0 which is incompatible. thinc 8.0.15 requires typing-extensions<4.0.0.0,>=3.7.4.1; python_version < "3.8", but you have typing-extensions 4.1.1 which is incompatible.
sphinx-rtd-theme 0.5.2 requires docutils<0.17, but you have docutils 0.17.1 which is incompatible. spacy 3.2.3 requires typing-extensions<4.0.0.0,>=3.7.4; python_version < "3.8", but you have typing-extensions 4.1.1 which is incompatible.
paddlepaddle-tiny 1.6.1 requires numpy<=1.16.4,>=1.12, but you have numpy 1.19.5 which is incompatible.  
flake8 5.0.4 requires importlib-metadata<4.3,>=1.1.0; python_version < "3.8", but you have importlib-metadata 4.8.3 which is incompatible.
datasets 1.2.0 requires tqdm<4.50.0,>=4.27, but you have tqdm 4.64.1 which is incompatible.  
argcomplete 1.11.1 requires importlib-metadata<2,>=0.23; python_version == "3.6", but you have importlib-metadata 4.8.3 which is incompatible.  
allennlp 1.0.0 requires filelock<3.1,>=3.0, but you have filelock 3.4.1 which is incompatible.  
allennlp 1.0.0 requires overrides==3.0.0, but you have overrides 6.1.0 which is incompatible.
allennlp 1.0.0 requires spacy<2.3,>=2.1.0, but you have spacy 3.2.3 which is incompatible.
allennlp 1.0.0 requires torch<1.6.0,>=1.5.0, but you have torch 1.10.0 which is incompatible.
allennlp 1.0.0 requires transformers<2.12,>=2.9, but you have transformers 4.18.0 which is incompatible. 
opennmt-py 1.0.0 requires tqdm~=4.30.0, but you have tqdm 4.64.1 which is incompatible.
Successfully installed certifi-2022.12.7 charset-normalizer-2.0.12 click-8.0.4 dataclasses-0.8 filelock-3.4.1 huggingface-hub-0.4.0 idna-3.4 importlib-metadata-4.8.3 importlib-resources-5.4.0 joblib-1.1.1 numpy-1.19.5 packaging-21.3 pyparsing-3.0.9 pyyaml-6.0 regex-2022.10.31 requests-2.27.1 sacremoses-0.0.53 six-1.16.0 tokenizers-0.12.1 tqdm-4.64.1 transformers-4.18.0 typing-extensions-4.1.1 urllib3-1.26.14 zipp-3.6.0
```

Then, I try to import transformers, and get the same error.
```
(py36)
cyx@c9 ~                                                                                                                                                                                                                                                          
  % python                                                                                                       !10078
Python 3.6.9 |Anaconda, Inc.| (default, Jul 30 2019, 19:07:31) 
[GCC 7.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy as np
>>> np.__version__
'1.19.5'
>>> np.__file__                                                                                                                                                                                                                                                '/home/cyx/.conda/envs/py36/lib/python3.6/site-packages/numpy/__init__.py'                                                                                                                                                                                
>>> import transformers
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/cyx/.conda/envs/py36/lib/python3.6/site-packages/transformers/__init__.py", line 30, in <module>
    from . import dependency_versions_check
  File "/home/cyx/.conda/envs/py36/lib/python3.6/site-packages/transformers/dependency_versions_check.py", line 41, in <module>
    require_version_core(deps[pkg])
  File "/home/cyx/.conda/envs/py36/lib/python3.6/site-packages/transformers/utils/versions.py", line 120, in require_version_core
    return require_version(requirement, hint)
  File "/home/cyx/.conda/envs/py36/lib/python3.6/site-packages/transformers/utils/versions.py", line 114, in require_version
    _compare_versions(op, got_ver, want_ver, requirement, pkg, hint)
  File "/home/cyx/.conda/envs/py36/lib/python3.6/site-packages/transformers/utils/versions.py", line 50, in _compare_versions
    f"{requirement} is required for a normal functioning of this module, but found {pkg}=={got_ver}.{hint}"
ImportError: numpy>=1.17 is required for a normal functioning of this module, but found numpy==1.16.4.
Try: pip install transformers -U or pip install -e '.[dev]' if you're working with git main
>>> 
```<|||||>
I think I found the answer.

While `pip list | grep numpy ` only returns 1.19.5 version, `conda list | grep numpy ` returns multiple versions:
```
(py36)                       
cyx@c9 ~                   
  % conda list | grep numpy                          
numpy                     1.19.2           py36h54aff64_0                 
numpy                     1.16.4                    <pip>    
numpy                     1.19.5                    <pip>    
numpy-base                1.19.2           py36hfa32c7d_0  
```
Then, I went to the conda env dir: `/data/home/cyx/.conda/envs/py36/lib/python3.6/site-packages`, and find there is a folder named `numpy-1.16.4.dist-info` and a folder named `numpy-1.19.5.dist-info`. After removing the 1.16.4 folder, I can import transformers correctly.

I wonder maybe the version checking function could be updated?<|||||>I had the same issue and ran:

pip show numpy | grep Location
rm -rvf /usr/local/lib/python3.11/site-packages/numpy
python3.11 -m pip install numpy

and this resolved it