Open Source RDBMS - Seamless, Scalable, Stable and Free

한국어 | Login |Register

[Solved] Python: ImportError: No module named CUBRIDdb


Today I encountered this "ImportError: No module named CUBRIDdb" error when trying to install and use the Python driver for CUBRID 8.4.3 on CentOS 5.6 x64. To install the driver I followed Create a CUBRID Database VM with Vagrant and Chef Cookbook under 5 minutes tutorial.

After everything was successfully installed, I created a simple Python program which executes a SELECT query. When I ran the program, I have received the following error:

$ python cubrid_example.py 
Traceback (most recent call last):
  File "cubrid_example.py", line 1, in ?
    import CUBRIDdb
ImportError: No module named CUBRIDdb

Problem

The problem happened to be due to these two facts:

  1. On CentOS 5.x by default Python 2.4 is installed.
  2. The pip Python package installer has droped Python 2.4 support since version 1.2. The minimum requirement now is Python 2.5.

For these reasons the Python cookbook installs Python 2.6 on CentOS 5.x and configures pip and virtualenv on top of Python 2.6, not Python 2.4. Thus:

  1. you end up having two versions of Python: 2.4 and 2.6;
  2. the CUBRID-Python driver installed via pip is available only for Python 2.6.

So, when I ran python cubrid_example.py it used the default Python 2.4, and of course, the CUBRID driver is not available there.

Solution

There are two solution to this problem:

  1. Use Python 2.6 executable as shown below
    $python26 cubrid_example.py
  2.  Or install CUBRID Python driver from source manually for Python 2.4 without pip or easy_install.

Both solutions work fine.

comments powered by Disqus
Page info
viewed 2290 times
translations en
Author
posted last year by
CUBRID
Contributors
updated last year by
View revisions
Share this article