python and pygresql install issues

Need help with C, C++, perl, python, etc?

python and pygresql install issues

Postby rodericj » 2006-06-22 14:41

Relatively new to debian and apt-get so bear with me.

I am looking to connect to my postgresql db through python.

so I do the following:

Code: Select all
apt-get install python-pygresql


Then in the python interactive shell

Code: Select all
>>> import pg
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
ImportError: No module named pg
>>> import pygresql
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
ImportError: No module named pygresql


What am I missing?

And for further reference: Where is the documentation when you install something through apt-get? I've had similar issues before. Like with ruby on rails and such. Sometimes the install works correctly but I just don't know how to take the next step.

Thoughts?
rodericj
 
Posts: 11
Joined: 2006-06-22 14:37

Postby Lavene » 2006-06-22 15:37

Try:
Code: Select all
>>> import _pg

That is import space underscore pg

Most packages install some documentation under /usr/share/doc/ so you'll find a readme in /usr/share/doc/python2.3-pygresql
The readme often contain information on where to find more documenation.

Tina :)
Lavene
Site admin
 
Posts: 5096
Joined: 2006-01-04 04:26
Location: Oslo, Norway

Postby rodericj » 2006-06-22 15:42

Thanks for the reply...but...

Code: Select all
$ python
Python 2.4.1 (#2, May  5 2005, 11:32:06)
[GCC 3.3.5 (Debian 1:3.3.5-12)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import _pg
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
ImportError: No module named _pg
>>>



Not quite...I'll look around in that directory for something..
rodericj
 
Posts: 11
Joined: 2006-06-22 14:37

Postby rodericj » 2006-06-22 16:00

Interesting:

Code: Select all
$ cd /usr/lib/python2.3
$ find . |grep pg
./site-packages/pg.py
./site-packages/pg.pyo
./site-packages/pgdb.py
./site-packages/_pg.so
./site-packages/pgdb.pyo
./site-packages/pg.pyc
./site-packages/pgdb.pyc
$


So if that is where it is installed, do I need to put /usr/lib/python2.3/site-packages/ in my $PYTHONPATH ?

That seems odd.

For now that works. Is there a better way to do this?
rodericj
 
Posts: 11
Joined: 2006-06-22 14:37

Postby Lavene » 2006-06-22 16:07

Ah... just noticed it was under python 2.3:

Python 2.3.5 (#2, Mar 6 2006, 10:12:24)
[GCC 4.0.3 20060304 (prerelease) (Debian 4.0.2-10)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import _pg
>>>


Wheras
Python 2.4.2 (#2, Nov 20 2005, 17:04:48)
[GCC 4.0.3 20051111 (prerelease) (Debian 4.0.2-4)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import _pg
Traceback (most recent call last):
File "<stdin>", line 1, in ?
ImportError: No module named _pg
>>>


Sorry about the confusion...

You need to
Code: Select all
apt-get install python2.4-pygresql



Tina
Lavene
Site admin
 
Posts: 5096
Joined: 2006-01-04 04:26
Location: Oslo, Norway


Return to Programming

Who is online

Users browsing this forum: No registered users and 7 guests

fashionable