0

I am working on Windows 10 with Python 3.9.7 and have anaconda setup on my laptop. I have compiled a C++ code calcSim.cpp where the module name is calJaccSimm and am able to successfully generate a .pyd file with the following extension .cp39-win_amd64.pyd as described here .

I am launching my jupyter notebook at the following location: jupyter-notebook D:\projects\sem4\code and my .pyd file named calcSim.cp39-win_amd64.pyd is at the same location.

When trying to import module using:

import calJaccSimm I am getting ModuleNotFoundError.

I have tried the following things:

  1. import sys

    sys.path.insert(0, 'D:\projects\sem4\code')

  2. import os

    os.dll_directory("D:\projects\sem4\code")

  3. Setup environment variables with the path '"D:\projects\sem4\code"'

  4. Tried putting the generated .pyd in different locations like anaconda\DLLs and anaconda\lib\site-packages folder.

But after all this, I am still not able to load the module. Please help.

Edit 1: I had multiple versions of python on my machine. I deleted all the versions and re-installed anaconda as well. Still facing the same issue.

tushaR
  • 3,083
  • 1
  • 20
  • 33

1 Answers1

1

There are three places where the module name needs to be consistent: When calling the PYBIND11_MODULE macro, in the file name of the extension, and in the import statement inside python.

It seems that your pyd file is inconsistently named calcSim instead of calcJaccSimm.

unddoch
  • 5,790
  • 1
  • 24
  • 37
  • Thanks a lot. I had tried the same thing earlier as well but it did not work then because of multiple python versions issue. – tushaR Feb 26 '23 at 11:58