Windows: can't find _sqlite3_cffi.pypy-41.pyd although it is here

Create issue
Issue #2988 resolved
Armin Rigo created an issue

A user reports getting this message on Windows (6.0.0 worked fine, 7.0.0 and 7.1.0 fail):

'C:\pypy2\lib_pypy\_sqlite3_cffi.pypy-41.pyd': The specified module could not be found

This occurs as soon as he tries to import sqlite3. More information from him:

I've tested it on two different Win10 PCs (32bit PyPy on
64bit Win10) and both exhibit the same behaviour.

I've got the answer: With PyPy version >= 7.0.0 you have
to add PyPy's root folder to PATH in Environment Variables,
that wasn't required with versions <= 6.0.0

This is not the answer, though, because for me on a very similar setting it just works fine, without setting any PATH. If we could reproduce this it would be great.

Comments (8)

  1. Armin Rigo reporter

    OK, a minute after posting this I managed to reproduce the problem. You have to run pypy.exe from elsewhere with \full\path\to\pypy.exe, and then it won't find this module.

  2. mattip

    Just before you import sqlite3, what is the os.environ['PATH']? Perhaps we added os.dirname(sys.executable) in 6.0 and not in 7.0? According to the discussion in this PR for cpython, apparently better policy is to put the dlls next to the pyds, so they should be in lib_pypy.

  3. Armin Rigo reporter

    As a quick workaround you can move sqlite3.dll from the pypy directory into the lib_pypy subdirectory. This makes it work again. But it used to work with sqlite3.dll there, so we still need to figure it out.

  4. Armin Rigo reporter

    os.environ['PATH'] is the same in old and new versions and doesn't contain any pypy path.

  5. Armin Rigo reporter

    I also tried to copy _sqlite3_cffi.pypy-41.pyd between versions, but it has no effect, so it's not a difference in how this file is built.

  6. mattip

    It is due to a change we made in loading cffi, c-extension modules,and ctypes dlls. You need to copy the dll files to lib_pypy.

    Fixed in da158a6f6a35 for a future release

  7. Log in to comment