Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ImportError: No module named psycopg2

In installation process of OpenERP 6, I want to generate a config file with these commands:

cd /home/openerp/openerp-server/bin/ 
./openerp-server.py -s --stop-after-init -c /home/openerp/openerp-server.cfg 

But it always showed the message: ImportError: No module named psycopg2

When I checked for psycopg2 package, it's already installed. Package python-psycopg2-2.4.5-1.rhel5.x86_64 is already installed to its latest version. Nothing to do. What's wrong with this? My server is CentOS, I've installed Python 2.6.7.

like image 970
ws_123 Avatar asked Oct 16 '12 01:10

ws_123


People also ask

How do you fix ModuleNotFoundError No module named psycopg2?

The Python "ModuleNotFoundError: No module named 'psycopg2'" occurs when we forget to install the psycopg2-binary module before importing it or install it in an incorrect environment. To solve the error, install the module by running the pip install psycopg2-binary command.


2 Answers

Step 1: Install the dependencies

sudo apt-get install build-dep python-psycopg2 

Step 2: Run this command in your virtualenv

pip install psycopg2-binary  

Ref: Fernando Munoz

like image 123
Tarique Avatar answered Sep 23 '22 06:09

Tarique


Use psycopg2-binary instead of psycopg2.

pip install psycopg2-binary 

Or you will get the warning below:

UserWarning: The psycopg2 wheel package will be renamed from release 2.8; in order to keep installing from binary please use "pip install psycopg2-binary" instead. For details see: http://initd.org/psycopg/docs/install.html#binary-install-from-pypi.

Reference: Psycopg 2.7.4 released | Psycopg

like image 29
Yan QiDong Avatar answered Sep 19 '22 06:09

Yan QiDong