在安装OpenERP 6的过程时,我想用这个命令生成一个配置文件,
cd / home / openerp / openerp-server / bin /
./openerp-server.py -s --stop-after-init -c /home/openerp/openerp-server.cfg
但它总是显示出一个信息
ImportError: No module named psycopg2
当我检查psycopg2包时,它已经安装好,
包python-psycopg2-2.4.5-1.rhel5.x86_64
已安装和最新版本
没事做
这有什么问题?
我的服务器是CentOS,我已经安装了python 2.6.7。
第1步:安装依赖项
sudo apt-get install build-dep python-psycopg2
第2步:在virtualenv中运行此命令
pip install psycopg2
请尝试在python控制台上运行命令import psycopg2
。如果你得到错误,那么检查python查找安装模块的sys.path
。如果python-psycopg2-2.4.5-1.rhel5.x86_64
的父目录是否在sys.path
中。如果它不在sys.path
然后在运行openerp服务器之前运行export PYTHONPATH=<parent directory of python-psycopg2-2.4.5-1.rhel5.x86_64>
。
试试这些:
virtualenv -p /usr/bin/python3 test_env
source test_env/bin/activate
pip install psycopg2
运行python并尝试导入,如果你坚持在你的系统python上安装它尝试:
pip3 install psycopg2
我遇到了同样的问题并使用以下命令解决了这个问题:
sudo apt-get install libpq-dev
pip install psycopg2
您需要安装psycopg2
模块。
在CentOS上:确保安装了Python 2.7+。如果没有,请按照以下说明操作:http://toomuchdata.com/2014/02/16/how-to-install-python-on-centos/
# Python 2.7.6:
$ wget http://python.org/ftp/python/2.7.6/Python-2.7.6.tar.xz
$ tar xf Python-2.7.6.tar.xz
$ cd Python-2.7.6
$ ./configure --prefix=/usr/local --enable-unicode=ucs4 --enable-shared LDFLAGS="-Wl,-rpath /usr/local/lib"
$ make && make altinstall
$ yum install postgresql-libs
# First get the setup script for Setuptools:
$ wget https://bitbucket.org/pypa/setuptools/raw/bootstrap/ez_setup.py
# Then install it for Python 2.7 and/or Python 3.3:
$ python2.7 ez_setup.py
$ easy_install-2.7 psycopg2
即使这是一个CentOS问题,这里是Ubuntu的说明:
$ sudo apt-get install python3-pip python-distribute python-dev
$ easy_install psycopg2
最近在我的生产服务器上面临这个问题。我已经安装了pyscopg2
sudo pip install psycopg2
它在我的本地工作得非常漂亮,但让我在我的ec2服务器上运行。
sudo python -m pip install psycopg2
上面的命令对我有用。在这里发布,以防将来有人帮助。
使用psycopg2-binary而不是psycopg2。
pip install psycopg2-binary
或者您将收到以下警告:
UserWarning:psycopg2 wheel包将从2.8版重命名;为了继续从二进制安装,请使用“pip install psycopg2-binary”代替。有关详细信息,请参阅:http://initd.org/psycopg/docs/install.html#binary-install-from-pypi。
对于Python3
第1步:安装依赖项
sudo apt-get install python3 python-dev python3-dev
第2步:安装
pip install psycopg2