Search code examples
pythonzodb

Fedora: No module named 'ZODB' in Python 3


How can I install ZODB for Python 3? I installed python-ZODB3 in Fedora, but I can use ZODB only in Python 2:

$ python
Python 2.7.5 (default, Sep 25 2014, 13:57:38) 
[GCC 4.8.3 20140911 (Red Hat 4.8.3-7)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import ZODB
>>> quit()
$ python3
Python 3.3.2 (default, Jun 30 2014, 17:20:03) 
[GCC 4.8.3 20140624 (Red Hat 4.8.3-1)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import ZODB
Traceback (most recent call last):
  File "/usr/lib64/python3.3/code.py", line 90, in runcode
    exec(code, self.locals)
  File "<console>", line 1, in <module>
ImportError: No module named 'ZODB'

Which package am I missing?


Solution

  • In general, the Fedora name for Python package foo for Python 3.x is python3-foo, not python-foo3.

    In particular, python-ZODB3 is the Python 2.x package for ZODB3. (ZODB3 is the obsolete version 3 of ZODB, still provided for backward compatibility.) Both the old 3.x and new 4.x versions of ZODB work for both Python 2.x and 3.x; that means there are (at least potentially) packages named python-ZODB (ZODB 4.x for Python 2.x), python3-ZODB (4.x for 3.x), python-ZODB3 (3.x for 2.x), and python3-ZODB3 (3.x for 3.x). It's the second one you want, not the third.

    I can't guarantee that your Fedora version and repos have a python3-ZODB RPM, but from a quick search, I found this, so at least some Fedora-based systems have one.

    If there's not a Fedora RPM for that, you can probably install it via pip, something like pip3 install ZODB.