Support Questions
Find answers, ask questions, and share your expertise
Alert: Welcome to the Unified Cloudera Community. Former HCC members be sure to read and learn how to activate your account here.

Hue wont start - No module named psycopg2

Re: Hue wont start - No module named psycopg2


Just want to add some info. that can help others who are facing the same issue.


In my case,

- RHEL 7.2
- CDH 5.9.0

- Installation using ./cloudera-manager-installer.bin

After 60-day trial, Cloudera Enterprise, somehow Cloudera Managemet node is running out of memory.

RAM total = 16GB (15.5GB)

Used RAM = 12.7GB


Luckly I use VM server so it is easy to increase the memory.

Solution: Increse RAM from 16GB to 32GB and restart all services (Cloudera Servcies and others etc.)

The error disappears.


Proposed solution to do the softlink, it doesn't work.

sudo ln -s /usr/lib64/python2.7/site-packages/psycopg2 /opt/cloudera/parcels/CDH/lib/hue/build/env/lib/python2.7/site-packages


Because /usr/lib64/python2.7/site-packages/psycopg2 already contains a bounce of compiled python files.

You cannot create a softlink when there are already files in that directory.








Re: Hue wont start - No module named psycopg2


I was having problems installing HUE from CDH 5.9.0. The installation process kept failing on "Test DB Connection Step". The logs showed that a python version that comes with the CDH (and is used by HUE) package does not have psycopg2 module.


As a future reminder for myself and a quick fix for others, I will leave here the lines to install the modules:


/opt/cloudera/parcels/CDH-5.9.0-1.cdh5.9.0.p0.23/lib/hue/build/env/bin/python -m easy_install psycopg2
/opt/cloudera/parcels/CDH-5.9.0-1.cdh5.9.0.p0.23/lib/hue/build/env/bin/python2 -m easy_install psycopg2
/opt/cloudera/parcels/CDH-5.9.0-1.cdh5.9.0.p0.23/lib/hue/build/env/bin/python2.7 -m easy_install psycopg2



Re: Hue wont start - No module named psycopg2

Hue uses virtual environment where default site-package path is
"/usr/lib/python/site-packages" where VER could be 2.6, 2.7 etc..
For few OS python-psycopg2 python rpm package installation goes in
"/usr/lib/python/site-packages". But for others OS it varies from
1. /usr/lib64/python/site-packages
2. /usr/lib/python/dest-packages
3. /usr/lib64/python/dest-packages

Hue's virtual environment could not locate above paths(1,2 & 3) as when
creating HUE virtual environment(on build machine) these paths does not
exist. It looks like CM's agent installs python-psycopg2 package on CDH

We have two solutions for this issue.

1. Link psycopg2 python module under hue's directory structure :
2. Set PYTHONPATH in HUE service handler script :

#1 is valid as the package needs to be installed anyway, and a symlink
would work too. Doc will be updated too.
#2 will be in CM 5.10

Re: Hue wont start - No module named psycopg2

New Contributor

Thank you @Romainr for the reply and clear explannation. I assumed the same when copying the libraries since 'import psycopg2' worked in pyhton shell but hue is refrering to  /usr/lib/hue/build/env/lib/python2.7/site-packages/ path rather  /usr/lib64/python2.7/site-packages/ (where python shell refers)