Support Questions
Find answers, ask questions, and share your expertise
Announcements
Alert: Welcome to the Unified Cloudera Community. Former HCC members be sure to read and learn how to activate your account here. Want to know more about what has changed? Check out the Community News blog.

Hue wont start - No module named psycopg2

Hue wont start - No module named psycopg2

New Contributor

Hue Server won't start.. keeps complaining on python load of module pyscopg2.

+ /usr/lib/hue/build/env/bin/hue migrate --merge
Traceback (most recent call last):
  File "/usr/lib/hue/build/env/bin/hue", line 13, in <module>
    load_entry_point('desktop==3.9.0', 'console_scripts', 'hue')()
  File "/usr/lib/hue/desktop/core/src/desktop/manage_entry.py", line 64, in entry
    raise e
django.core.exceptions.ImproperlyConfigured: Error loading psycopg2 module: No module named psycopg2
+ '[' dumpdata = runcpserver ']'
+ '[' syncdb = runcpserver ']'
+ exec /usr/lib/hue/build/env/bin/hue runcpserver
Traceback (most recent call last):
  File "/usr/lib/hue/build/env/bin/hue", line 13, in <module>
    load_entry_point('desktop==3.9.0', 'console_scripts', 'hue')()
  File "/usr/lib/hue/desktop/core/src/desktop/manage_entry.py", line 64, in entry
    raise e
django.core.exceptions.ImproperlyConfigured: Error loading psycopg2 module: No module named psycopg2

 

 

However, from command line
[root@cscvmrhel01 bin]# python
Python 2.7.5 (default, Oct 11 2015, 17:47:16)
[GCC 4.8.3 20140911 (Red Hat 4.8.3-9)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import psycopg2
>>> import psycopg2
>>>

No errors reported.

 

Any Suggestions?

13 REPLIES 13

Re: Hue wont start - No module named psycopg2

Cloudera Employee

Make sure the psycopg2 package is installed for the certified Python version Hue is using and that Hue's Python sys.path variable points to the right directory/directories. Pls post it here if you got anywhere with it.

Re: Hue wont start - No module named psycopg2

Cloudera Employee

Another solution can be reinstalling the psycopg2 rpm package if already installed it before installing CDH. I read it somewhere this solved problems similar to Yours @RobertH.

Highlighted

Re: Hue wont start - No module named psycopg2

New Contributor

I had the same issue with Cloudera 5.9.0 on CentOS 7 and I was able to resolve the issue by copying the files from /usr/lib64/python2.7/site-packages/psycopg2* to /usr/lib/hue/build/env/lib/python2.7/site-packages/

Re: Hue wont start - No module named psycopg2

Cloudera Employee

@Choolake thank you for your input. Please stay tuned for news on this matter.

Re: Hue wont start - No module named psycopg2

Contributor

this fixed the problem for me also, but it does feel like an ugly hack for some bug.

Re: Hue wont start - No module named psycopg2

Cloudera Employee

Hmm that's weird. I just brought up a 4 node cluster without a problem from archive.cloudera.com like this:

  • CentOS 7.2 + yum update -y
  • Oracle JDK 1.7u67
  • CM 5.9.0 from RPM with embedded PostgreSQL (cloudera-manager-server-db-2+cloudera-manager-server)
  • CDH 5.9.0 from CM with parcels
  • python-psycopg2-2.5.1-3.el7.x86_64 is installed by CM as well

  • only Hue and its dependencies, started without problem

I only experienced problems when installing C5.8+ on CentOS 5.x. What did you do differently regarding the C5.9.0+CentOS7.x install @Choolake?

Re: Hue wont start - No module named psycopg2

New Contributor

I used, 

CentOS: 7.2

JAVA: 1.8.0_102

psycopg2: psycopg2-2.6.2-py2.7

and CM 5.9.0 from RPM with external postgresql-9.4

 

 

Re: Hue wont start - No module named psycopg2

Cloudera Employee

Hi, @Choolake, you should not need to do anything special with psycopg2 on CentOS 7.

 

This should work for CDH 5.9 on CentOS 7 with JDK 1.8 ... and PostgreSQL 9.4 (which I put on a separate host): 

 

#################################
## All hosts in the cluster
#################################
yum update -y
wget --no-check-certificate --no-cookies --header "Cookie: oraclelicense=accept-securebackup-cookie" http://download.oracle.com/otn-pub/java/jdk/8u102-b14/jdk-8u102-linux-x64.rpm
rpm -ivh jdk-8u102-linux-x64.rpm

 

## Set vm.swappiness=10
vi /etc/sysctl.conf
cat /proc/sys/vm/swappiness
sudo sysctl -w vm.swappiness=10


#################################
## Primary host in cluster
#################################
yum update -y
wget https://archive.cloudera.com/cm5/redhat/7/x86_64/cm/cloudera-manager.repo -P /etc/yum.repos.d/
yum install -y cloudera-manager-daemons cloudera-manager-server
yum install -y cloudera-manager-server-db-2
service cloudera-scm-server-db start
service cloudera-scm-server start

 

#################################
## Database host (ideally, not in cluster)
#################################
yum -y update
rpm -ivh http://yum.postgresql.org/9.4/redhat/rhel-7-x86_64/pgdg-centos94-9.4-1.noarch.rpm
yum install postgresql94-server -y
/usr/pgsql-9.4/bin/postgresql94-setup initdb

 

## Configure per: http://www.cloudera.com/documentation/enterprise/latest/topics/hue_ins_connect_db.html#concept_lpg_r...
vi /var/lib/pgsql/9.4/data/pg_hba.conf
vi /var/lib/pgsql/9.4/data/postgresql.conf

 

systemctl enable postgresql-9.4.service
systemctl start postgresql-9.4.service

 

## Create database per: http://www.cloudera.com/documentation/enterprise/latest/topics/hue_ins_connect_db.html#concept_rq3_m...
sudo -u postgres psql
psql -h localhost -U hue -d hue

 


Finally, run the Cloudera Manager wizard in a browser and connect to the external database server (with port 5432) on the Database Setup page.

 

Re: Hue wont start - No module named psycopg2

Explorer

This issue also happens for us on RHEL 7.2 using the following simple installation path for a POC:

wget https://archive.cloudera.com/cm5/installer/latest/cloudera-manager-installer.bin

chmod u+x cloudera-manager-installer.bin

sudo ./cloudera-manager-installer.bin --i-agree-to-all-licenses --noprompt --noreadme --nooptions

Hue fails to start with missing module psycopg2 error.

 

I created a symlink using following command and successfully started Hue:

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

Thanks @Choolake & @Romainr for workaround.