Charles Merriam
Charles Merriam

Reputation: 20530

Import errors on subsystems for ZODB, but only for Py.Test

Running PyTest with files including ZODB gives an odd problem: ZODB can be imported, but its component FileSystem cannot.

import ZODB   # That works fine.
import ZODB.FileStorage
ImportError: No module named FileStorage

On the other hand, running the same code from the Python interpreter runs fine.

This is version PyTest version 3.2.2, Python 2.7.13, and ZODB 5.2.4 There exists ZODB-5.2.4-py2.7.egg/ZODB/FileStorage/init.py, a ZODB.pth pointing to the egg, and no other modules have issues; just any submodule of ZODB. No odd permission errors. After an hour of experiments and exercising Google-Fu, I got nothing.

Any workaround would be appreciated.

Well, I dropped this because it 'went away'. Now its back. This I know so far:

Things I see:

  * Same issue from PyCharm or command line.
  * No issue running normal code from PyCharm or command line.
  * Once it starts to be an issue, it continues.  Still don't know why.
  * Once it goes away it stays away.
  * My edit configuration has a warning "No Py.Test runner found for current configuration", though 
  /opt/zzz/bin/py.test is in path
  * Seems to have occurred after a reboot.
  * No reason, at all, to suspect FileStorage.
  * This is in my ...../site-packages directory:


        $ ls -l ZODB*
        -rw-rw-r--  1 cmerriam  zzz  23 Oct  6 18:08 ZODB.pth

        ZODB-5.2.4-py2.7.egg:
        total 0
        drwxr-xr-x   9 cmerriam  zzz   306 Oct  6 18:08 EGG-INFO/
        drwxr-xr-x  74 cmerriam  zzz  2516 Oct  9 15:58 ZODB/


        $ cd ZODB-5.2.4-py2.7.egg
        $ tree
           |-EGG-INFO
           |-ZODB
           |---FileStorage
           |---__pycache__
           |---scripts
           |-----manual_tests
           |-----tests
           |---tests

Things that haven't worked:

Aha! A CLUE!

There exists in the system a module named zzz.data.zodb.py. And I'm working on OS/X which is case preserving but not case sensitive. And yet I got a point with both "zzz.data.zodb" and "zzz.data.ZODB" in my sys.modules. And can we just make it an error to have two items align but for case yet?

I still would like nail down the edge cases of what happened.

Upvotes: 5

Views: 240

Answers (2)

user8749048
user8749048

Reputation:

Try Something Like the following as discribed in another answer:

@A. Dickey -

from ZODB import FileStorage

In the comments discribes:

@nes -
Maybe module with same name located in sys.path. Try to see which files module uses import ZODB; print(ZODB.__file__)

Upvotes: -1

A. Dickey
A. Dickey

Reputation: 141

Have you tried the following:

from ZODB import FileStorage

Upvotes: 0

Related Questions