Thread: Trouble installing psycopg2

Trouble installing psycopg2

From
Laura Tateosian
Date:
Hi,  I'm trying to install psycopg2 on a Centos 5, 64-bit machine.   I have both 2.4 and 2.7 Python versions on this machine.  I attempted to install using
easy-install2.7 psycopg2

The install is not working.  (I can't import psycopg2 in a python 2.7 session).   yum doesn't list it as installed.  But when I try to install it again, easy_install responds that it's already installed.  That's the short version of the problem, more details below that may or may not be helpful.

Thanks,
LT




At first, easy-install2.7 psycopg2 gave me similar errors to what's described on this page: http://stackoverflow.com/questions/9600111/install-pg-config-in-centos-5-5-without-yum (something to do with pg_config not found).  So I followed the advice of installing devel

yum install postgresql84-devel

...succeeded.

Then, I  "easy-install2.7 psycopg2" again.  In fact I piped the output to a file and got what I have below, but it also flashed up an error message which didn't get into this file and I can't see on the history.  But from that second  that I saw it, I know it had __FILE__ in it.   Now I'm in this installed/but not installed kind of limbo.
...
Excluding Packages in global exclude list
Finished
Available Packages
python-psycopg2.x86_64                      2.0.14-2.el5                 epel
python-psycopg2-doc.x86_64                  2.0.14-2.el5                 epel
python-psycopg2-zope.x86_64                 2.0.14-2.el5                 epel
root@server [/opt/bin]# easy_install-2.7 psycopg2
Searching for psycopg2
Searching for psycopg2
Reading http://pypi.python.org/simple/psycopg2/
Reading http://initd.org/projects/psycopg2
Best match: psycopg2 2.5.1
Downloading https://pypi.python.org/packages/source/p/psycopg2/psycopg2-2.5.1
.tar.gz#md5=1b433f83d50d1bc61e09026e906d84c7
Processing psycopg2-2.5.1.tar.gz
Writing /tmp/easy_install-UYNn1g/psycopg2-2.5.1/setup.cfg
Running psycopg2-2.5.1/setup.py -q bdist_egg --dist-dir /tmp/easy_install-UYN
n1g/psycopg2-2.5.1/egg-dist-tmp-FLKSTs
Adding psycopg2 2.5.1 to easy-install.pth file

Installed /usr/local/lib/python2.7/site-packages/psycopg2-2.5.1-py2.7-linux-x
86_64.egg
Processing dependencies for psycopg2
Finished processing dependencies for psycopg2

Re: Trouble installing psycopg2

From
David Kerr
Date:
On Thu, Sep 26, 2013 at 01:01:54PM -0400, Laura Tateosian wrote:
- Hi,  I'm trying to install psycopg2 on a Centos 5, 64-bit machine.   I have
- both 2.4 and 2.7 Python versions on this machine.  I attempted to install
- using
- easy-install2.7 psycopg2
-
- The install is not working.  (I can't import psycopg2 in a python 2.7
- session).   yum doesn't list it as installed.  But when I try to install it
- again, easy_install responds that it's already installed.  That's the short
- version of the problem, more details below that may or may not be helpful.
-
- Thanks,
- LT
-
-
-
-
- At first, easy-install2.7 psycopg2 gave me similar errors to what's
- described on this page:
- http://stackoverflow.com/questions/9600111/install-pg-config-in-centos-5-5-without-yum(something
- to do with pg_config not found).  So I followed the advice of
- installing devel
-
- yum install postgresql84-devel
-
- ...succeeded.
-
- Then, I  "easy-install2.7 psycopg2" again.  In fact I piped the output to a
- file and got what I have below, but it also flashed up an error message
- which didn't get into this file and I can't see on the history.  But from
- that second  that I saw it, I know it had __FILE__ in it.   Now I'm in this
- installed/but not installed kind of limbo.
- ...
- Excluding Packages in global exclude list
- Finished
- Available Packages
- python-psycopg2.x86_64                      2.0.14-2.el5
- epel
- python-psycopg2-doc.x86_64                  2.0.14-2.el5
- epel
- python-psycopg2-zope.x86_64                 2.0.14-2.el5
- epel
- root@server [/opt/bin]# easy_install-2.7 psycopg2
- Searching for psycopg2
- Searching for psycopg2
- Reading http://pypi.python.org/simple/psycopg2/
- Reading http://initd.org/projects/psycopg2
- Best match: psycopg2 2.5.1
- Downloading
- https://pypi.python.org/packages/source/p/psycopg2/psycopg2-2.5.1
- .tar.gz#md5=1b433f83d50d1bc61e09026e906d84c7
- Processing psycopg2-2.5.1.tar.gz
- Writing /tmp/easy_install-UYNn1g/psycopg2-2.5.1/setup.cfg
- Running psycopg2-2.5.1/setup.py -q bdist_egg --dist-dir
- /tmp/easy_install-UYN
- n1g/psycopg2-2.5.1/egg-dist-tmp-FLKSTs
- Adding psycopg2 2.5.1 to easy-install.pth file
-
- Installed
- /usr/local/lib/python2.7/site-packages/psycopg2-2.5.1-py2.7-linux-x
- 86_64.egg
- Processing dependencies for psycopg2
- Finished processing dependencies for psycopg2


So easy_install isn't going to intall the yum version, and it may install it somewhere
that the system python isn't looking for it.

That's generally why you  don't want to use easy_install or pip if you can avoid it.
If you DO use them you should use virtualenv and virtualenvwrapper.

Since you have an OS package, Your best bet is to do 'yum install python-psycopg2'
and see if that works for you.



Re: Trouble installing psycopg2

From
Chris Curvey
Date:



On Thu, Sep 26, 2013 at 1:01 PM, Laura Tateosian <augori@gmail.com> wrote:
Hi,  I'm trying to install psycopg2 on a Centos 5, 64-bit machine.   I have both 2.4 and 2.7 Python versions on this machine.  I attempted to install using
easy-install2.7 psycopg2

The install is not working.  (I can't import psycopg2 in a python 2.7 session).   yum doesn't list it as installed. 

Yum won't show it.  (Yum is an OS-level package manager, easy_install is a python-level package manager)
 
But when I try to install it again, easy_install responds that it's already installed.  That's the short version of the problem, more details below that may or may not be helpful.

Hmm.  If you're absolutely sure that it's python2.7 that  you're running, I would get out the big hammer.  Got to /usr/local/lib/python2.7/site-packages, and rm(dir) anything related to psycopg2.  Then look in any "*.pth" files and delete lines related to psycopg2.  Then try re-running easy_install.

You would definitely need the -devel packages for PG because easy_install is trying to compile a C module.  But I've done the same thing before (tried to install psycopg2 w/o the devel package installed), and just an ordinary re-run fixed it for me.


Re: Trouble installing psycopg2

From
Augori
Date:
Thanks, for the replies Chris and David.   

Chris, I couldn't find any psycopg files under my Python installs, so I decided to try David's advice and yum install python-psycopg2
It reported success, but it installed it under ../usr/lib64/python2.4/site-packages

I'm working with Python2.7.5, so psycopg2 won't import.   It believe that psycopg2 is not written for 2.4 or below.  That's why I installed 2.7.5.  So my question now is, how can I get yum to install it in the 2.7 site-packages?

Thanks.

PS.  About the virtualenv suggestion, I had tried using use virtualenv and virtualenvwrapper, following the instructions on this nice site.  http://bda.ath.cx/blog/2009/04/08/installing-python-26-in-centos-5-or-rhel5/
But, I couldn't get the bashrc to run without error, after adding this update
source /opt/bin/virtualenvwrapper_bashrc

So, I thought I'd throw caution to the wind and skip that part.
(that's how I got to easy_intall, which at least allowed me to specify
which python version)

Re: Trouble installing psycopg2

From
David Kerr
Date:
On Thu, Sep 26, 2013 at 02:56:14PM -0400, Augori wrote:
- Thanks, for the replies Chris and David.
-
- Chris, I couldn't find any psycopg files under my Python installs, so I
- decided to try David's advice and yum install python-psycopg2
- It reported success, but it installed it under
- ../usr/lib64/python2.4/site-packages
-
- I'm working with Python2.7.5, so psycopg2 won't import.   It believe that
- psycopg2 is not written for 2.4 or below.  That's why I installed 2.7.5.
- So my question now is, how can I get yum to install it in the 2.7
- site-packages?
-
- Thanks.
-
- PS.  About the virtualenv suggestion, I had tried using use virtualenv and
- virtualenvwrapper, following the instructions on this nice site.
- http://bda.ath.cx/blog/2009/04/08/installing-python-26-in-centos-5-or-rhel5/
- But, I couldn't get the bashrc to run without error, after adding this
- update
-
- source /opt/bin/virtualenvwrapper_bashrc
-
- So, I thought I'd throw caution to the wind and skip that part.
- (that's how I got to easy_intall, which at least allowed me to specify
- which python version)

Looking at the easy_install on my system it uses python26
head -1 /usr/bin/easy_install
#!/usr/bin/python2.6

so if you use easy_install you probably just installed it to the 2.6 stuff.

If you need 2.7 for your stuff then you'll definitely want to get virtualenv
working. If you can live with 2.6 then get rid of 2.7 on your machine
and work with the yum packages.

A better virtualenvwrapper setup doc is here (not from 2009)
http://virtualenvwrapper.readthedocs.org/en/latest/



Re: Trouble installing psycopg2

From
Adrian Klaver
Date:
On 09/26/2013 11:56 AM, Augori wrote:
> Thanks, for the replies Chris and David.
>
> Chris, I couldn't find any psycopg files under my Python installs, so I
> decided to try David's advice and yum install python-psycopg2
> It reported success, but it installed it under
> ../usr/lib64/python2.4/site-packages

The easy_install version was not under?:

/usr/local/lib/python2.7/site-packages/


--
Adrian Klaver
adrian.klaver@gmail.com


Re: Trouble installing psycopg2

From
Augori
Date:
Okay, I'm sorry for the questions.  But I'm really confused about where things are being installed.  I know that yum installed it under 2.4 site-packages because I checked for it inside there before and after I ran the yum command.  

There is an easy_install.pth file under /usr/local/lib/python2.7/site-
packages/ as well, but would that be invoked when I call easy_install when I'm logged in as root?

As for 2.6, that would be fine, but I don't seem to have a /user/bin/python2.6 (whereas, I do have a  /user/bin/python2.4). Maybe it's because I'm on CentOS5, which comes with 2.4.

I tried to use the rpm --prefix flag to move the rpm, but to no avail.


On Thu, Sep 26, 2013 at 5:02 PM, Adrian Klaver <adrian.klaver@gmail.com> wrote:
On 09/26/2013 11:56 AM, Augori wrote:
Thanks, for the replies Chris and David.

Chris, I couldn't find any psycopg files under my Python installs, so I
decided to try David's advice and yum install python-psycopg2
It reported success, but it installed it under
../usr/lib64/python2.4/site-packages

The easy_install version was not under?:

/usr/local/lib/python2.7/site-packages/


--
Adrian Klaver
adrian.klaver@gmail.com

Re: Trouble installing psycopg2

From
Adrian Klaver
Date:
On 09/26/2013 02:14 PM, Augori wrote:
> Okay, I'm sorry for the questions.  But I'm really confused about where
> things are being installed.  I know that yum installed it under 2.4
> site-packages because I checked for it inside there before and after I
> ran the yum command.
>
> There is an easy_install.pth file under /usr/local/lib/python2.7/site-
> packages/ as well, but would that be invoked when I call easy_install
> when I'm logged in as root?
>
> As for 2.6, that would be fine, but I don't seem to have a
> /user/bin/python2.6 (whereas, I do have a  /user/bin/python2.4). Maybe
> it's because I'm on CentOS5, which comes with 2.4.
>
> I tried to use the rpm --prefix flag to move the rpm, but to no avail.
>

Well you said you have both Python 2.4 and 2.7 installed on the machine.

Were they both installed via Centos package management?

If so Python 2.4 is probably set as the default and if you install the
package for Python it will install for 2.4. You probably need to specify
the python version. Not sure how Centos names its packages, but I am
using openSUSE and the default package(where the default Python is 2.7)
is python-psycopg2 and the Python 3 version(which I also have installed)
is python3-psycopg2


--
Adrian Klaver
adrian.klaver@gmail.com


Re: Trouble installing psycopg2

From
Augori
Date:
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.

I think you're right about Python2.4 being set as the default.  Does anyone know how to persuade it otherwise for installation purposes?

Thanks.


On Thu, Sep 26, 2013 at 5:30 PM, Adrian Klaver <adrian.klaver@gmail.com> wrote:
On 09/26/2013 02:14 PM, Augori wrote:
Okay, I'm sorry for the questions.  But I'm really confused about where
things are being installed.  I know that yum installed it under 2.4
site-packages because I checked for it inside there before and after I
ran the yum command.

There is an easy_install.pth file under /usr/local/lib/python2.7/site-
packages/ as well, but would that be invoked when I call easy_install
when I'm logged in as root?

As for 2.6, that would be fine, but I don't seem to have a
/user/bin/python2.6 (whereas, I do have a  /user/bin/python2.4). Maybe
it's because I'm on CentOS5, which comes with 2.4.

I tried to use the rpm --prefix flag to move the rpm, but to no avail.


Well you said you have both Python 2.4 and 2.7 installed on the machine.

Were they both installed via Centos package management?

If so Python 2.4 is probably set as the default and if you install the package for Python it will install for 2.4. You probably need to specify the python version. Not sure how Centos names its packages, but I am using openSUSE and the default package(where the default Python is 2.7) is python-psycopg2 and the Python 3 version(which I also have installed) is python3-psycopg2


--
Adrian Klaver
adrian.klaver@gmail.com

Re: Trouble installing psycopg2

From
John R Pierce
Date:
On 9/26/2013 7:07 PM, Augori wrote:
> I think you're right about Python2.4 being set as the default.  Does
> anyone know how to persuade it otherwise for installation purposes?
>

path.

absolutely do NOT replace the OS distribution python unless you want to
break lots of stuff (for instance, yum on rhel/centos is written in python)



--
john r pierce                                      37N 122W
somewhere on the middle of the left coast



Re: Trouble installing psycopg2

From
Adrian Klaver
Date:
On 09/26/2013 07:07 PM, Augori wrote:
> 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.

No.

>
> I think you're right about Python2.4 being set as the default.  Does
> anyone know how to persuade it otherwise for installation purposes?

Well it seems you already have psycopg2 installed for Python 2.7, it
just cannot find it. Here is a possible solution.

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


Re: Trouble installing psycopg2

From
Augori
Date:
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:
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.

No.



I think you're right about Python2.4 being set as the default.  Does
anyone know how to persuade it otherwise for installation purposes?

Well it seems you already have psycopg2 installed for Python 2.7, it just cannot find it. Here is a possible solution.

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

Re: Trouble installing psycopg2

From
Adrian Klaver
Date:
On 09/27/2013 04:45 AM, Augori wrote:
> *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:*
>

Yes, an egg is just a zip file that at the destination may remain zipped
or be unzipped into a directory:

http://stackoverflow.com/questions/2051192/what-is-a-python-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. *

So you have two versions of Python 2.7 in play, this complicates the issue.

>

> *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

Probably because programs are being installed in the other version of
Python 2.7

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

It is the default Python and the one CentOS is using when it
installs/updates Python.

>
> *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:*
>

That is correct Python 2.7 needs a version of psycopg2 compiled for it
not 2.4.

>
> Do you have other ideas?

Clean house. Uninstall the two versions of Python 2.7 you have and start
over.

A bit of Googling found the below, it refers to CentOS 6 but is pointed
to by people as useful on CentOS 5 also.

http://toomuchdata.com/2012/06/25/how-to-install-python-2-7-3-on-centos-6-2/

--
Adrian Klaver
adrian.klaver@gmail.com


Re: Trouble installing psycopg2

From
Adrian Klaver
Date:
On 09/27/2013 04:45 AM, Augori wrote:

>
> Do you have other ideas?
>

Re: my previous post. I was assuming you are not using Python 2.7 for
anything important at this point. That might be an erroneous assumption,
in which case truly cleaning house might not be the way to go.


--
Adrian Klaver
adrian.klaver@gmail.com


Re: Trouble installing psycopg2

From
Augori
Date:
Thanks to Adrian for pointing to this site.  http://toomuchdata.com/2012/06/25/how-to-install-python-2-7-3-on-centos-6-2/  I was able to get the virtual environment set up and install psycopg2 from there.  Now things seem to be working well when I'm logged in as root.  

But I need to be able to use the virtualenv as a non-root user, joshmoe.  (And start/stop postgresql as this other user)

The command for getting into the virtualenv is: 

source /root/Python-2.7.3/projectdir/bin/activate

Understandably, when I run this command as joshmoe, I get a permission denied message:
-bash: /root/Python-2.7.3/projectdir/bin/activate: Permission denied

In an attempt to make this command available to joshmoe,  I started with chmod and gave all rwx.  Still gave me the same message. So I edited /etc/sudoer to include the following line:

joshmoe ALL=NOPASSWD: /root/Python-2.7.3/projectdir/bin/activate

Now from the joshmoe login, when I run:

sudo source /root/Python-2.7.3/projectdir/bin/activate

I get the following:

sudo: source: command not found

It seems pretty clear to me that I'm not using the sudoers file correctly to specify sourcing this file -- I seem to be giving access to that activate file successfully, but not to the built-in source function.  Both of following lines are a no-go in the sudoers file-- syntax error

joshmoe ALL=NOPASSWD: source 

joshmoe ALL=NOPASSWD: source /root/Python-2.7.3/projectdir/bin/activate

I've found a good many examples of sudoer statements.  But I can't figure out the syntax that will make this work.  I'm hoping once I get this one, I'll be able to give access to statements like 'service postgresql status' and so forth.
  

On Fri, Sep 27, 2013 at 10:58 AM, Adrian Klaver <adrian.klaver@gmail.com> wrote:
On 09/27/2013 04:45 AM, Augori wrote:


Do you have other ideas?


Re: my previous post. I was assuming you are not using Python 2.7 for anything important at this point. That might be an erroneous assumption, in which case truly cleaning house might not be the way to go.


--
Adrian Klaver
adrian.klaver@gmail.com

Re: Trouble installing psycopg2

From
Adrian Klaver
Date:
On 09/29/2013 09:38 AM, Augori wrote:
> Thanks to Adrian for pointing to this site.
> http://toomuchdata.com/2012/06/25/how-to-install-python-2-7-3-on-centos-6-2/
>   I was able to get the virtual environment set up and install psycopg2
> from there.  Now things seem to be working well when I'm logged in as root.
>
> But I need to be able to use the virtualenv as a non-root user, joshmoe.
>   (And start/stop postgresql as this other user)

> I've found a good many examples of sudoer statements.  But I can't
> figure out the syntax that will make this work.  I'm hoping once I get
> this one, I'll be able to give access to statements like 'service
> postgresql status' and so forth.


Looks to me you installed the virtualenv as user root into /root. Why
not install the virtualenv as joshme into /joshme? Then you avoid the
sudo problems all together. It also one of the benefits of virtualenv
you can run programs as an ordinary user and not make them system wide.


--
Adrian Klaver
adrian.klaver@gmail.com


Re: Trouble installing psycopg2

From
Augori
Date:
You're right, I installed the virtualenv as user root into /root.  

The reason for this is that I can't run 'yum' and probably many of the other commands from joshmoe, so I gave up on that route.  But I'm open for suggestions...do you think it would be better to try to get access to these commands? 


On Sun, Sep 29, 2013 at 12:46 PM, Adrian Klaver <adrian.klaver@gmail.com> wrote:
On 09/29/2013 09:38 AM, Augori wrote:
Thanks to Adrian for pointing to this site.
http://toomuchdata.com/2012/06/25/how-to-install-python-2-7-3-on-centos-6-2/
  I was able to get the virtual environment set up and install psycopg2
from there.  Now things seem to be working well when I'm logged in as root.

But I need to be able to use the virtualenv as a non-root user, joshmoe.
  (And start/stop postgresql as this other user)

I've found a good many examples of sudoer statements.  But I can't
figure out the syntax that will make this work.  I'm hoping once I get
this one, I'll be able to give access to statements like 'service
postgresql status' and so forth.


Looks to me you installed the virtualenv as user root into /root. Why not install the virtualenv as joshme into /joshme? Then you avoid the sudo problems all together. It also one of the benefits of virtualenv you can run programs as an ordinary user and not make them system wide.


--
Adrian Klaver
adrian.klaver@gmail.com

Re: Trouble installing psycopg2

From
Augori
Date:
No, sorry.  I just checked that again and I can yum.  I guess I remembered that incorrectly.

But the thing is, I'm worried that I have all this stuff set up and working --postgresql, virtualenv, psycopg2 in root; then if I try another install under joshmoe it could cause even more more chaos. 


On Sun, Sep 29, 2013 at 1:01 PM, Augori <augori@gmail.com> wrote:
You're right, I installed the virtualenv as user root into /root.  

The reason for this is that I can't run 'yum' and probably many of the other commands from joshmoe, so I gave up on that route.  But I'm open for suggestions...do you think it would be better to try to get access to these commands? 


On Sun, Sep 29, 2013 at 12:46 PM, Adrian Klaver <adrian.klaver@gmail.com> wrote:
On 09/29/2013 09:38 AM, Augori wrote:
Thanks to Adrian for pointing to this site.
http://toomuchdata.com/2012/06/25/how-to-install-python-2-7-3-on-centos-6-2/
  I was able to get the virtual environment set up and install psycopg2
from there.  Now things seem to be working well when I'm logged in as root.

But I need to be able to use the virtualenv as a non-root user, joshmoe.
  (And start/stop postgresql as this other user)

I've found a good many examples of sudoer statements.  But I can't
figure out the syntax that will make this work.  I'm hoping once I get
this one, I'll be able to give access to statements like 'service
postgresql status' and so forth.


Looks to me you installed the virtualenv as user root into /root. Why not install the virtualenv as joshme into /joshme? Then you avoid the sudo problems all together. It also one of the benefits of virtualenv you can run programs as an ordinary user and not make them system wide.


--
Adrian Klaver
adrian.klaver@gmail.com


Re: Trouble installing psycopg2

From
Augori
Date:
Hmm maybe you're right.  I just tried starting over again from a directory under joshmoe, following the tutorial again, but I get permssions errors at every turn. 

# wget http://python.org/ftp/python/2.7.3/Python-2.7.3.tar.bz2
# tar xf Python-2.7.3.tar.bz2
# cd Python-2.7.3
# ./configure --prefix=/usr/local
# make && make altinstall
Running the make && make altinstall looks okay for a bit (maybe during the build), but then fas with the permissions errors below:

Failed to build these modules:
_sqlite3

running build_scripts
creating build/scripts-2.7
copying and adjusting /home/realmark/public_html/cronjobs/gisSupportCode/Pyth
on-2.7.3/Tools/scripts/pydoc -> build/scripts-2.7
copying and adjusting /home/realmark/public_html/cronjobs/gisSupportCode/Pyth
on-2.7.3/Tools/scripts/idle -> build/scripts-2.7
copying and adjusting /home/realmark/public_html/cronjobs/gisSupportCode/Pyth
on-2.7.3/Tools/scripts/2to3 -> build/scripts-2.7
copying and adjusting /home/realmark/public_html/cronjobs/gisSupportCode/Pyth
on-2.7.3/Lib/smtpd.py -> build/scripts-2.7
changing mode of build/scripts-2.7/pydoc from 644 to 755
changing mode of build/scripts-2.7/idle from 644 to 755
changing mode of build/scripts-2.7/2to3 from 644 to 755
changing mode of build/scripts-2.7/smtpd.py from 644 to 755
/usr/bin/install -c -m 644 ./Tools/gdb/libpython.py python-gdb.py
/usr/bin/install -c python /usr/local/bin/python2.7
/usr/bin/install: cannot remove `/usr/local/bin/python2.7': Permission denied
make: *** [altbininstall] Error 1

Since it's already their, I thought maybe I could skip to these steps but they give permission errors as well
# wget http://pypi.python.org/packages/source/d/distribute/distribute-0.6.35.tar.gz
# tar xf distribute-0.6.35.tar.gz
# cd distribute-0.6.35
# python2.7 setup.py install
I guess this is the reason I started installing things from root.



On Sun, Sep 29, 2013 at 1:15 PM, Augori <augori@gmail.com> wrote:
No, sorry.  I just checked that again and I can yum.  I guess I remembered that incorrectly.

But the thing is, I'm worried that I have all this stuff set up and working --postgresql, virtualenv, psycopg2 in root; then if I try another install under joshmoe it could cause even more more chaos. 


On Sun, Sep 29, 2013 at 1:01 PM, Augori <augori@gmail.com> wrote:
You're right, I installed the virtualenv as user root into /root.  

The reason for this is that I can't run 'yum' and probably many of the other commands from joshmoe, so I gave up on that route.  But I'm open for suggestions...do you think it would be better to try to get access to these commands? 


On Sun, Sep 29, 2013 at 12:46 PM, Adrian Klaver <adrian.klaver@gmail.com> wrote:
On 09/29/2013 09:38 AM, Augori wrote:
Thanks to Adrian for pointing to this site.
http://toomuchdata.com/2012/06/25/how-to-install-python-2-7-3-on-centos-6-2/
  I was able to get the virtual environment set up and install psycopg2
from there.  Now things seem to be working well when I'm logged in as root.

But I need to be able to use the virtualenv as a non-root user, joshmoe.
  (And start/stop postgresql as this other user)

I've found a good many examples of sudoer statements.  But I can't
figure out the syntax that will make this work.  I'm hoping once I get
this one, I'll be able to give access to statements like 'service
postgresql status' and so forth.


Looks to me you installed the virtualenv as user root into /root. Why not install the virtualenv as joshme into /joshme? Then you avoid the sudo problems all together. It also one of the benefits of virtualenv you can run programs as an ordinary user and not make them system wide.


--
Adrian Klaver
adrian.klaver@gmail.com



Re: Trouble installing psycopg2

From
Adrian Klaver
Date:
On 09/29/2013 11:06 AM, Augori wrote:
> Hmm maybe you're right.  I just tried starting over again from a
> directory under joshmoe, following the tutorial again, but I get
> permssions errors at every turn.
>
> # wgethttp://python.org/ftp/python/2.7.3/Python-2.7.3.tar.bz2
> # tar xf Python-2.7.3.tar.bz2
> # cd Python-2.7.3
> # ./configure --prefix=/usr/local
> # make && makealtinstall
>



>
> Since it's already their, I thought maybe I could skip to these steps
> but they give permission errors as well
>
> # wgethttp://pypi.python.org/packages/source/d/distribute/distribute-0.6.35.tar.gz
> # tar xf distribute-0.6.35.tar.gz
> # cd distribute-0.6.35
> # python2.7 setup.py install
>
> I guess this is the reason I started installing things from root.
>


The above steps should be run as root preferably via sudo. You have
already done that as well as the step that installed virtualenv. My
suggestion was to run the below as joshmoe in joshmoes home directory:

virtualenv-2.7 --distribute someproject

source someproject/bin/activate
(someproject)# python --version

Then install psycopg2 in that virtualenv.

This assumes you want to run psycopg2 in a virtualenv. I am not sure
what the end point of all this i.e. how you want to use psycopg2?


--
Adrian Klaver
adrian.klaver@gmail.com