2

After installing pytorch package, I have tried to import pytorch with

import torch

but got the error

Traceback (most recent call last):
  File "<console>", line 1, in <module>
  File "c:\users\user\appdata\local\programs\python\python38\lib\site-packages\torch\__init__.py", line 190, in <module>
    from torch._C import *
ValueError: module functions cannot set METH_CLASS or METH_STATIC

from searching, I have read that this could be about numpy. So I have tried uninstalling and installing with those

pip uninstall numpy
pip install numpy -I
pip install numpy -U

It didn't work.

I would be happy to hear from you if you have any idea why such an error occurs and how to correct it?

in case needed: Python version 3.8.6 , torch version 1.7.0 , numpy version 1.19.4

1
  • Can you try going back to an older version of numpy, say, 1.16.5? Commented Nov 22, 2020 at 12:02

1 Answer 1

3

The latest version of numpy for the moment is 1.19.4

I have uninstalled numpy and installed 1.19.3 version. After a complete restart of the system. The error does not show anymore. Thanks.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.