Import of transformers package throwing value_error
Author: valmetisrinivas
Pull request: no

I have successfully installed transformers package in my Jupyter Notebook from Anaconda administrator console using the command 'conda install -c conda-forge transformers'.

However when I try to load the transformers package in my Jupyter notebook using 'import transformers' command, I am getting an error, 'ValueError: got_ver is None'. 

I am not sure how I can resolve this. Appreciate any inputs.


Comments:
Do you get the same error when installing from our conda channel?

```
conda install -c huggingface transformers
```

> 
> 
> Do you get the same error when installing from our conda channel?
> 
> ```
> conda install -c huggingface transformers
> ```

Hi, I don't see the problem while installing. Installation goes through successfully. I have reproduced the installation screen shot below. The error message appears when loading the 'transformers' package in Jupyter NB. by the way, as you can see below, I have installed using the above suggested channel too, but the same error persists, while loading the package. Thank you.

(base) C:\WINDOWS\system32>conda install -c conda-forge transformers
Collecting package metadata (current_repodata.json): done
Solving environment: done

## Package Plan ##

  environment location: C:\ProgramData\Anaconda3

  added / updated specs:
    - transformers


The following packages will be downloaded:

    package                    |            build
    ---------------------------|-----------------
    dataclasses-0.8            |     pyhc8e2a94_3          10 KB  conda-forge
    huggingface_hub-0.0.16     |     pyhd8ed1ab_0          52 KB  conda-forge
    sacremoses-0.0.43          |     pyh9f0ad1d_0         430 KB  conda-forge
    tokenizers-0.10.1          |   py38h291c280_0         1.9 MB  conda-forge
    transformers-4.9.2         |     pyhd8ed1ab_0         1.3 MB  conda-forge
    typing-extensions-3.10.0.0 |       hd8ed1ab_0           8 KB  conda-forge
    typing_extensions-3.10.0.0 |     pyha770c72_0          28 KB  conda-forge
    ------------------------------------------------------------
                                           Total:         3.7 MB

The following NEW packages will be INSTALLED:

  dataclasses        conda-forge/noarch::dataclasses-0.8-pyhc8e2a94_3
  huggingface_hub    conda-forge/noarch::huggingface_hub-0.0.16-pyhd8ed1ab_0
  sacremoses         conda-forge/noarch::sacremoses-0.0.43-pyh9f0ad1d_0
  tokenizers         conda-forge/win-64::tokenizers-0.10.1-py38h291c280_0
  transformers       conda-forge/noarch::transformers-4.9.2-pyhd8ed1ab_0
  typing-extensions  conda-forge/noarch::typing-extensions-3.10.0.0-hd8ed1ab_0

The following packages will be UPDATED:

  typing_extensions  pkgs/main::typing_extensions-3.7.4.3-~ --> conda-forge::typing_extensions-3.10.0.0-pyha770c72_0


Proceed ([y]/n)?


Downloading and Extracting Packages
typing_extensions-3. | 28 KB     | ##################################################################################################### | 100%
huggingface_hub-0.0. | 52 KB     | ##################################################################################################### | 100%
typing-extensions-3. | 8 KB      | ##################################################################################################### | 100%
dataclasses-0.8      | 10 KB     | ##################################################################################################### | 100%
sacremoses-0.0.43    | 430 KB    | ##################################################################################################### | 100%
transformers-4.9.2   | 1.3 MB    | ##################################################################################################### | 100%
tokenizers-0.10.1    | 1.9 MB    | ##################################################################################################### | 100%
Preparing transaction: done
Verifying transaction: done
Executing transaction: done

(base) C:\WINDOWS\system32>conda install -c huggingface transformers
Collecting package metadata (current_repodata.json): done
Solving environment: done

## Package Plan ##

  environment location: C:\ProgramData\Anaconda3

  added / updated specs:
    - transformers


The following packages will be UPDATED:

  ca-certificates    conda-forge::ca-certificates-2021.5.3~ --> pkgs/main::ca-certificates-2021.7.5-haa95532_1

The following packages will be SUPERSEDED by a higher-priority channel:

  certifi            conda-forge::certifi-2021.5.30-py38ha~ --> pkgs/main::certifi-2021.5.30-py38haa95532_0


Proceed ([y]/n)?

Preparing transaction: done
Verifying transaction: done
Executing transaction: done

(base) C:\WINDOWS\system32>

Hmmm I have trouble reproducing. If you have it handy, do you mind pasting the full stack trace? Thank you

Hi @LysandreJik, Sorry for getting back late. I have tried many things including installation and reinstallation of `transformers `several times.

1.  Whether I uninstall or remove the package using commands like `conda uninstall -c pypi transformers` or `conda uninstall -c conda-forge transformers`, or `conda uninstall transformers` or `conda remove transformers` from Anaconda prompt, or using `pip uninstall transformers` from within Jupyter, the `transformers` module continues to show up when I check using `conda list`. Please see the picture.
![conda packages](https://user-images.githubusercontent.com/51160232/132469706-7eb27cb2-baec-4124-a3f3-0a2affd79d1e.jpg)

2.  After reinstalling using `conda install -c huggingface transformers` from Anaconda prompt, the below commands and the out put clearly indicate the package is installed.
```
import transformers
help(transformers)
```
```
Help on package transformers:

NAME
    transformers

PACKAGE CONTENTS
    activations
    activations_tf
    benchmark (package)
    commands (package)
    configuration_utils
    convert_graph_to_onnx
    convert_pytorch_checkpoint_to_tf2
    convert_slow_tokenizer
    convert_slow_tokenizers_checkpoints_to_fast
    convert_tf_hub_seq_to_seq_bert_to_pytorch
    data (package)
    debug_utils
    deepspeed
    dependency_versions_check
    dependency_versions_table
    feature_extraction_sequence_utils
    feature_extraction_utils
    file_utils
    generation_beam_search
    generation_flax_logits_process
    generation_flax_utils
    generation_logits_process
    generation_stopping_criteria
    generation_tf_utils
    generation_utils
    hf_argparser
    image_utils
    integrations
    modelcard
    modeling_flax_outputs
    modeling_flax_pytorch_utils
    modeling_flax_utils
    modeling_outputs
    modeling_tf_outputs
    modeling_tf_pytorch_utils
    modeling_tf_utils
    modeling_utils
    models (package)
    onnx (package)
    optimization
    optimization_tf
    pipelines (package)
    sagemaker (package)
    testing_utils
    tokenization_utils
    tokenization_utils_base
    tokenization_utils_fast
    trainer
    trainer_callback
    trainer_pt_utils
    trainer_seq2seq
    trainer_tf
    trainer_utils
    training_args
    training_args_seq2seq
    training_args_tf
    utils (package)

FILE
    (built-in)
```
3. However, I am in doubt whether it installed the correct package and all sub-modules, because, I don't find popular sub-modules like `pipeline`, `AutoModelForTokenClassification`, `AutoTokenizer`.
4. When I try to import some sub-modules from the list shown above, some seem to get executed and some not. Below, the 1st one gets executed and not the second one (gives an error message).

5. `from transformers import activations_tf`
     `from transformers import activations`
```
---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
~\AppData\Local\Temp/ipykernel_6928/4272544316.py in <module>
----> 1 from transformers import activations

C:\ProgramData\Anaconda3\lib\site-packages\transformers\activations.py in <module>
     19 from torch import nn
     20 
---> 21 from .utils import logging
     22 
     23 

C:\ProgramData\Anaconda3\lib\site-packages\transformers\utils\__init__.py in <module>
     17 from packaging import version
     18 
---> 19 from .. import __version__
     20 
     21 

ImportError: cannot import name '__version__' from 'transformers' (unknown location)
```

Other than getting frustrated, I am unable to figure out what is the problem. Hope I get the help.




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/master/CONTRIBUTING.md) are likely to be ignored.

I still hope this can be resolved. Hope someone can help.

On Tue, 5 Oct 2021, 7:12 p.m. github-actions[bot], ***@***.***>
wrote:

> 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/master/CONTRIBUTING.md>
> are likely to be ignored.
>
> —
> You are receiving this because you authored the thread.
> Reply to this email directly, view it on GitHub
> <https://github.com/huggingface/transformers/issues/13356#issuecomment-934499745>,
> or unsubscribe
> <https://github.com/notifications/unsubscribe-auth/AMGKJKEGAJIYKHIJVDFTTY3UFMIVFANCNFSM5DD4AMVA>
> .
> Triage notifications on the go with GitHub Mobile for iOS
> <https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675>
> or Android
> <https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>.
>
>


me too, same problem

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/master/CONTRIBUTING.md) are likely to be ignored.

Hi @valmetisrinivas , I meet the same issue and I found that I have two numpy package in my conda env (/home/xxx/anaconda3/env/xxx/lib/python3.x/site-package/numpy-1.xx.x.dist-info). After I remove the empty one(not have METADATA or version not correspond), everything goes fine. Hope it can help you

Thanks a lot. Appreciate.
reg,
Srinivas

On Wed, 8 Dec 2021 at 12:10, ynlee-43 ***@***.***> wrote:

> Hi @valmetisrinivas <https://github.com/valmetisrinivas> , I meet the
> same issue and I found that I have two numpy package in my conda env
> (/home/xxx/anaconda3/env/xxx/lib/python3.x/site-package). After I remove
> the empty one(not have METADATA or version not correspond), everything goes
> fine. Hope it can help you
>
> —
> You are receiving this because you were mentioned.
> Reply to this email directly, view it on GitHub
> <https://github.com/huggingface/transformers/issues/13356#issuecomment-988588290>,
> or unsubscribe
> <https://github.com/notifications/unsubscribe-auth/AMGKJKELWJHYBX6F7WXD2PLUP4HGFANCNFSM5DD4AMVA>
> .
> Triage notifications on the go with GitHub Mobile for iOS
> <https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675>
> or Android
> <https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>.
>
>


> Hi @valmetisrinivas , I meet the same issue and I found that I have two numpy package in my conda env (/home/xxx/anaconda3/env/xxx/lib/python3.x/site-package/numpy-1.xx.x.dist-info). After I remove the empty one(not have METADATA or version not correspond), everything goes fine. Hope it can help you

For others coming here: This was what helped me; I had installed `numpy` twice, once from `conda` and once via `pip`. Manually removing the folder, as per the comment above, did the trick. 

Tip: Copy the folder before doing any modifications; in case anything goes wrong you'll have a backup.

> 

Deleting empty dist-info folder of `numpy` really solves the problem. Thank you!