简体   繁体   中英

Pycharm error - OSError: [WinError 126] The specified module could not be found

I am trying to run my program on Pycharm but I am getting the following error

C:\Users\I323017\AppData\Local\Continuum\anaconda3\pythonw.exe C:/Users/I323017/PycharmProjects/question_answering_kinnal/src/main.py
Traceback (most recent call last):
  File "C:/Users/I323017/PycharmProjects/question_answering_kinnal/src/main.py", line 1, in <module>
    from src.dataset import PrepareDataSet
  File "C:\Users\I323017\PycharmProjects\question_answering_kinnal\src\dataset.py", line 7, in <module>
    from transformers import SquadExample, squad_convert_examples_to_features, AlbertTokenizer
  File "C:\Users\I323017\AppData\Local\Continuum\anaconda3\lib\site-packages\transformers\__init__.py", line 23, in <module>
    from .benchmark_utils import (
  File "C:\Users\I323017\AppData\Local\Continuum\anaconda3\lib\site-packages\transformers\benchmark_utils.py", line 14, in <module>
    from .file_utils import is_tf_available, is_torch_available
  File "C:\Users\I323017\AppData\Local\Continuum\anaconda3\lib\site-packages\transformers\file_utils.py", line 38, in <module>
    import torch
  File "C:\Users\I323017\AppData\Local\Continuum\anaconda3\lib\site-packages\torch\__init__.py", line 81, in <module>
    ctypes.CDLL(dll)
  File "C:\Users\I323017\AppData\Local\Continuum\anaconda3\lib\ctypes\__init__.py", line 356, in __init__
    self._handle = _dlopen(self._name, mode)
OSError: [WinError 126] The specified module could not be found

Process finished with exit code 1

Why am I getting the OSError: [WinError 126] The specified module could not be found when everything seems to be in place. Does this have to do something with the interpreter? Currently, I am using my Conda interpreter in Pycharm

Actually, I had a lot of unwanted packages and so I did a conda clean --yes --all and my Pycharm is not working since then.

It sounds like you have more than one interpreter, you probably installed this module on the other interpreter. I would switch interpreters and see if it works. In the future, if you wish to avoid these issues it would be wise to use a virtual environment.

From https://discuss.pytorch.org/t/cannot-import-torch-on-jupyter-notebook/79334 the problem seems to be because of installing the GPU version of PyTorch. In case there is no GPU driver in the host system, it is recommended to install the CPU version of Pytorch using

# Conda
conda install pytorch torchvision cpuonly -c pytorch
# Pip
pip install torch==1.5.0+cpu torchvision==0.6.0+cpu -f https://download.pytorch.org/whl/torch_stable.html

What I did was to enable Windows Long Path. After restarting everything works.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM