pytorch_geometric: `OSError: [WinError 127] The specified procedure could not be found` when importing torch_geometric

🐛 Bug

I could install torch-geometric via pip install torch-geometric without errors in my venv. Now when I run import torch_geometric a window pops up saying “The procedure entry point could not be located in the dynamic link library ...\env\Lib\site-packages\torch_sparse\_version_cpu.pyd.” The complete error message in the terminal reads:

(env) C:\Users\jonat\Documents\Studium\Masterarbeit>py
Python 3.9.0 (tags/v3.9.0:9cf6752, Oct  5 2020, 15:34:40) [MSC v.1927 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import torch_geometric
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Users\jonat\Documents\Studium\Masterarbeit\env\lib\site-packages\torch_geometric\__init__.py", line 7, in <module>
    import torch_geometric.data
  File "C:\Users\jonat\Documents\Studium\Masterarbeit\env\lib\site-packages\torch_geometric\data\__init__.py", line 1, in <module>
    from .data import Data
  File "C:\Users\jonat\Documents\Studium\Masterarbeit\env\lib\site-packages\torch_geometric\data\data.py", line 3, in <module>
    from torch_geometric.typing import OptTensor, NodeType, EdgeType
  File "C:\Users\jonat\Documents\Studium\Masterarbeit\env\lib\site-packages\torch_geometric\typing.py", line 4, in <module>
    from torch_sparse import SparseTensor
  File "C:\Users\jonat\Documents\Studium\Masterarbeit\env\lib\site-packages\torch_sparse\__init__.py", line 15, in <module>
    torch.ops.load_library(importlib.machinery.PathFinder().find_spec(
  File "C:\Users\jonat\Documents\Studium\Masterarbeit\env\lib\site-packages\torch\_ops.py", line 110, in load_library
    ctypes.CDLL(path)
  File "C:\Users\jonat\AppData\Local\Programs\Python\Python39\lib\ctypes\__init__.py", line 374, in __init__
    self._handle = _dlopen(self._name, mode)
OSError: [WinError 127] The specified procedure could not be found

So I also tried it outside the venv and got another error in the terminal (without a window popping up):

C:\Users\jonat\Documents\Studium\Masterarbeit>py
Python 3.9.0 (tags/v3.9.0:9cf6752, Oct  5 2020, 15:34:40) [MSC v.1927 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import torch_geometric
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Users\jonat\AppData\Local\Programs\Python\Python39\lib\site-packages\torch_geometric\__init__.py", line 7, in <module>
    import torch_geometric.data
  File "C:\Users\jonat\AppData\Local\Programs\Python\Python39\lib\site-packages\torch_geometric\data\__init__.py", line 1, in <module>
    from .data import Data
  File "C:\Users\jonat\AppData\Local\Programs\Python\Python39\lib\site-packages\torch_geometric\data\data.py", line 3, in <module>
    from torch_geometric.typing import OptTensor, NodeType, EdgeType
  File "C:\Users\jonat\AppData\Local\Programs\Python\Python39\lib\site-packages\torch_geometric\typing.py", line 4, in <module>
    from torch_sparse import SparseTensor
  File "C:\Users\jonat\AppData\Local\Programs\Python\Python39\lib\site-packages\torch_sparse\__init__.py", line 15, in <module>
    torch.ops.load_library(importlib.machinery.PathFinder().find_spec(
AttributeError: 'NoneType' object has no attribute 'origin'

I already read here https://github.com/pyg-team/pytorch_geometric/issues/2304 that *.so files in ...\torch_sparse might play a role; there are none in that folder. In most problems I could find about similar bugs, CUDA seems to have been the problem; however, I don’t even use CUDA. Does anyone know what could cause the problem and how I could go about fixing it?

Environment

  • OS: Windows 10
  • Python version: 3.9.0
  • PyTorch version: 1.7.1+cu110
  • CUDA/cuDNN version: no CUDA

About this issue

  • Original URL
  • State: open
  • Created 3 years ago
  • Comments: 21 (10 by maintainers)

Most upvoted comments

I was having the same issue with torch version 1.11.0 when importing torch_geometric datasets from torch_geometric.datasets import TUDataset

I was able to resolve with by uninstalling torch-geometric and all its dependencies with: pip uninstall torch-geometric torch-scatter torch-sparse torch-cluster torch-spline-conv

Making sure that torch-geometric is actually uninstalled by checking the packages installed in my anaconda env with: conda list

Turned out that I had multiple versions of these packages installed in my anaconda environment. The problem was, that I installed torch-geometric with cuda but I actually did not have my gpu connected so I needed to install the cpu version. Installing cpu version did not remove the already installed gpu version, hence creating a conflict.

After removing torch-geometric and all its dependencies, I used the PyG documentation to know which package versions were compatible:

image

Finally, according to the docs, I used this command: pip install torch-scatter torch-sparse torch-cluster torch-spline-conv torch-geometric -f https://data.pyg.org/whl/torch-1.11.0+cpu.html

The versions of dependencies installed were:

torch-geometric 2.0.4 torch-cluster 1.6.0 torch-scatter 2.0.9 torch-sparse 0.6.13 torch-spline-conv 1.2.1

Yes, still looking the same:

(env2) C:\Users\jonat\Documents\Studium\Masterarbeit>py
Python 3.9.0 (tags/v3.9.0:9cf6752, Oct  5 2020, 15:34:40) [MSC v.1927 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import torch_scatter
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Users\jonat\Documents\Studium\Masterarbeit\env2\lib\site-packages\torch_scatter\__init__.py", line 13, in <module>
    torch.ops.load_library(importlib.machinery.PathFinder().find_spec(
  File "C:\Users\jonat\Documents\Studium\Masterarbeit\env2\lib\site-packages\torch\_ops.py", line 110, in load_library
    ctypes.CDLL(path)
  File "C:\Users\jonat\AppData\Local\Programs\Python\Python39\lib\ctypes\__init__.py", line 374, in __init__
    self._handle = _dlopen(self._name, mode)
OSError: [WinError 127] The specified procedure could not be found

with a window popping up before the error message appears, which again says “The procedure entry point could not be located in the dynamic link library ...\env\Lib\site-packages\torch_scatter\_version_cpu.pyd.” Do you have any other ideas how this could be solved? If not, I’ve been thinking about just implementing some GNNs from scratch now, so you don’t have to spend any more time on this if you don’t feel like we can easily solve it.

Thank you! Can you try to run

pip install --verbose --no-index torch-scatter==2.0.7 -f https://data.pyg.org/whl/torch-1.7.1+Bcu110.html

as well, and report back the log?

Can you give some details about how you tried to install the external packages (torch-scatter, torch-sparse, …). Keep in mind that for older PyTorch versions, you may have to specify the version as well:

pip install torch-scatter==2.0.7 torch-sparse==0.6.9 torch-cluster==1.5.9 torch-spline-conv==1.2.1 -f https://data.pyg.org/whl/torch-1.7.1+Bcu110.html