Re: Trouble installing psycopg2 - Mailing list pgsql-general
From | Augori |
---|---|
Subject | Re: Trouble installing psycopg2 |
Date | |
Msg-id | CAFE+72MWUKQYjOeLA3U6ddywWB74=gbEamjp6YszZ65Q7DbrCA@mail.gmail.com Whole thread Raw |
In response to | Re: Trouble installing psycopg2 (Adrian Klaver <adrian.klaver@gmail.com>) |
Responses |
Re: Trouble installing psycopg2
Re: Trouble installing psycopg2 |
List | pgsql-general |
Thanks again for the suggestions. It doesn't look to me like it's installed in /usr/local/lib/python2.7/site-packages. There's an egg directory there, but otherwise, no psycopg2. The egg directory doesn't mean it's installed, does it?? Here's an ls of that site-packages dir:
root@server [/usr/bin]# ls /usr/local/lib/python2.7/site-packages
./ setuptools-0.6c11-py2.7.egg-info
../ setuptools.pth
distribute-0.6.35-py2.7.egg/ stevedore-0.12-py2.7.egg/
easy-install.pth virtualenv-1.9.1-py2.7.egg/
psycopg2-2.5.1-py2.7-linux-x86_64.egg/ virtualenv_clone-0.2.4-py2.7.egg/
README virtualenvwrapper-4.1.1-py2.7.egg/
setuptools-0.6c11-py2.7.egg
If I modify my sys.path, it still doesn't import psycopg2. The python command runs version 2.7.5 and you can see that in evidence in the sys path. It is looking at a different Python 2.7 that I installed under opt/bin and added to the PATH variable when I was trying to set up a virtualenvwrapper.
Here's a Python session:
root@server [/usr/bin]# python
Python 2.7.5 (default, Sep 25 2013, 10:45:19)
[GCC 4.1.2 20080704 (Red Hat 4.1.2-54)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> sys.path
['', '/opt/lib/python27.zip', '/opt/lib/python2.7', '/opt/lib/python2.7/plat-
linux2', '/opt/lib/python2.7/lib-tk', '/opt/lib/python2.7/lib-old', '/opt/lib
/python2.7/lib-dynload', '/opt/lib/python2.7/site-packages']
>>> sys.path.append('usr/local/lib/python2.7/site-packages')
>>> import psycopg2
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named psycopg2
But I can't get psycopg2 to install to the 2.7.5 directory. Its site-packages is completely empty:
root@server [/usr/bin]# ls /opt/lib/python2.7/site-packages
./ ../ README
whereas, /usr/lib64/python2.4/site-packages/ is full of stuff, including psycopg2. I've pasted just a small portion of the ls results below.
root@server [/usr/bin]# ls /usr/lib64/python2.4/site-packages/
ortableServer.py* xf86config.py
_gamin.a PortableServer.pyc* xf86config.pyc
_gamin.la* PortableServer.pyo* xf86config.pyo
gamin.py psycopg2/
I also tried appending this path and importing. That gives a different error --tries to import it but fails, probably because it's inside a 2.4 install:
root@server [/usr/bin]# python
Python 2.7.5 (default, Sep 25 2013, 10:45:19)
[GCC 4.1.2 20080704 (Red Hat 4.1.2-54)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> sys.path
['', '/opt/lib/python27.zip', '/opt/lib/python2.7', '/opt/lib/python2.7/plat-
linux2', '/opt/lib/python2.7/lib-tk', '/opt/lib/python2.7/lib-old', '/opt/lib
/python2.7/lib-dynload', '/opt/lib/python2.7/site-packages']
>>> sys.path.append('/usr/lib64/python2.4/site-packages/')
>>> import psycopg2
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib64/python2.4/site-packages/psycopg2/__init__.py", line 69, in
<module>
from _psycopg import BINARY, NUMBER, STRING, DATETIME, ROWID
ImportError: /usr/lib64/python2.4/site-packages/psycopg2/_psycopg.so: undefin
ed symbol: PyUnicodeUCS4_Decode
Do you have other ideas?
Thanks.
On Thu, Sep 26, 2013 at 11:52 PM, Adrian Klaver <adrian.klaver@gmail.com> wrote:
On 09/26/2013 07:07 PM, Augori wrote:No.I think Python 2.4 was installed with the OS. I installed Python 2.7
from an .egg file that I downloaded. I'm a bit new to this
terminology, so not sure if that considered Centos package management.Well it seems you already have psycopg2 installed for Python 2.7, it just cannot find it. Here is a possible solution.
I think you're right about Python2.4 being set as the default. Does
anyone know how to persuade it otherwise for installation purposes?
Open the Python 2.7 shell
import sys
then
sys.path
This will show a list of paths that Python 2.7 knows about. Look to see if /usr/local/lib/python2.7/site-packages/ is listed.
If not, you can temporarily include it by doing:
sys.path.append('/usr/local/lib/python2.7/site-packages/')
and then
import psycopg2
If it is indeed installed in /usr/local/lib/python2.7/site-packages/ it should load.
To make the change 'permanent' create a *.pth file in one of the directories shown when you first did sys.path, preferably a site-packages one. In the file put '/usr/local/lib/python2.7/site-packages/ . Then name the file, say usr_local.pth. Python adds directories in *.pth files to the sys.path.Thanks.
--
Adrian Klaver
adrian.klaver@gmail.com
pgsql-general by date: