Reply
New Contributor
Posts: 2
Registered: ‎11-04-2016

Hue wont start - No module named psycopg2

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?

Cloudera Employee
Posts: 4
Registered: ‎11-08-2016

Re: Hue wont start - No module named psycopg2

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.

Cloudera Employee
Posts: 4
Registered: ‎11-08-2016

Re: Hue wont start - No module named psycopg2

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.

New Contributor
Posts: 4
Registered: ‎11-29-2016

Re: Hue wont start - No module named psycopg2

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/

Cloudera Employee
Posts: 4
Registered: ‎11-08-2016

Re: Hue wont start - No module named psycopg2

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

Contributor
Posts: 27
Registered: ‎05-01-2015

Re: Hue wont start - No module named psycopg2

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

Cloudera Employee
Posts: 4
Registered: ‎11-08-2016

Re: Hue wont start - No module named psycopg2

[ Edited ]

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?

Cloudera Employee
Posts: 718
Registered: ‎07-30-2013

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
host.

We have two solutions for this issue.

1. Link psycopg2 python module under hue's directory structure :
/opt/cloudera/parcels/CDH/lib/hue/build/env/lib/python2.7/site-packages
2. Set PYTHONPATH in HUE service handler script :
/usr/lib64/cmf/service/hue/hue.sh

#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
New Contributor
Posts: 4
Registered: ‎11-29-2016

Re: Hue wont start - No module named psycopg2

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

 

 

New Contributor
Posts: 4
Registered: ‎11-29-2016

Re: Hue wont start - No module named psycopg2

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)

Announcements