Error "the PGXS Makefile cannot be found" when installing PostGis on Debian - postgresql

I am in the process of installing PostGis over psql on a Debian machine (actually crunchbang).
I have completed the following steps:
$ wget http://download.osgeo.org/postgis/source/postgis-2.0.3.tar.gz
$ tar xzf postgis-2.0.3.tar.gz
$ cd postgis-2.0.3
$ ./configure
On the final step I get the following error:
configure: error: the PGXS Makefile /usr/lib/postgresql/9.1/lib/pgxs/src/makefiles/pgxs.mk cannot be found. Please install the PostgreSQL server development packages and re-run configure.
The issue is that I do already have Postgres installed:
$ psql --version
psql (9.1.9)
I have checked this on two machines with the same configuration and get the same error. What am I missing here?

PostgreSQL is broken down into several packages, and having psql installed doesn't imply that the development packages are also installed.
According to the error message:
Please install the PostgreSQL server development packages and re-run
configure
you need:
# apt-get install postgresql-server-dev-9.1
Also note there's a APT pgdg repository providing recent pre-compiled versions of postgres-related packages (including postgis) that you may use instead of self-compiling.
If your system is set up to use this repository, just do:
# apt-get install postgresql-9.1-postgis-2.0

Daniel's answer works great except that it needs the following update:
$ sudo apt-get install postgresql-9.1-postgis-2.1
These packages can be updated some time in future again. So, it is recommended to search for new packages using aptitude and install the appropriate one:
$ aptitude search postgis

Related

Error while running 'make install' command to install Apache AGE

After successfully installing postgresql from source code, I got an error while installing Apache AGE. I have attached a screenshot of the error below. It would be great if someone can help out.Terminal view of command and error
I am searching online to find a solution but haven't been able to found yet.
From the image, it looks like you are using postgres 12.13.
For postgres 12, you should checkout to age for pg12 branch by doing git checkout release/PG12/1.1.1 and then make install.
I was also getting errors in a configuration which were resolved by using this command first.
sudo apt-get install build-essential libreadline-dev zlib1g-dev flex bison
Try this and this will solve your problem too
In addition to installing the essential libraries before the actual installation using:
sudo apt-get install build-essential libreadline-dev zlib1g-dev flex bison (Note: The above command is for Ubuntu only. If you are not on Ubuntu, See here)
It is also recommended to install the postgreSQL development files using:
sudo apt install postgresql-server-dev-xx
This is not the exact command to be typed in the terminal. Check out the link
here to see the exact compatible command to execute according to the version of Linux you are currently using.

Error while adding dependencies in order to install apache age

In order to install Apache age from source,
i am installing development files for PostgreSQL server-side programming. For this i am using following command on my Ubuntu OS.
sudo apt install postgresql-server-dev-11
But i am getting this error "Unable to locate package postgresql-server-dev-11"
image of the error
i am searching online but did not find yet.It would be great if someone help.
This is because you do not have the correct Ubuntu version and the package does not exist.
To determine the major PostgreSQL version in a given release of Ubuntu find it here in Ubuntu Packages
18.04 has PostgreSQL 10 (postgresql-server-dev-10)
19.04 has PostgreSQL 11 (postgresql-server-dev-11)
20.04 has PostgreSQL 12 (postgresql-server-dev-12)
If you have ubuntu 19.04 you can follow this guide
In the case there is no maintainer for the Version of PostgreSQL you are trying to install you have to build from source.
Download your PostgreSQL version source code. Then run these commands.
tar xf postgresql-version.tar.bz2
cd postgresql-version
Install dependencies. Then run the following.
./configure
make
su
make install
adduser postgres
mkdir -p /usr/local/pgsql/data
chown postgres /usr/local/pgsql/data
su - postgres
/usr/local/pgsql/bin/initdb -D /usr/local/pgsql/data
/usr/local/pgsql/bin/pg_ctl -D /usr/local/pgsql/data -l logfile start
/usr/local/pgsql/bin/createdb test
/usr/local/pgsql/bin/psql test
Reference from Official Docs
Seems the package is not available from your package manager. But, since you want development files, it's best to get the source code directly from GitHub.
In your home directory do:
git clone https://github.com/postgres/postgres.git
cd postgres
git checkout "REL_11_STABLE"
then follow this guide https://www.thegeekstuff.com/2009/04/linux-postgresql-install-and-configure-from-source/
Official documentation for installing from source is here https://www.postgresql.org/docs/current/installation.html
You should follow these steps:
sudo apt-get update
sudo apt-get -y install postgresql-12 postgresql-client-12
sudo systemctl status postgresql
I was also facing the same problem and i just updated my Ubunutu and the error got resolved when i run the command again
I faced the same issue on Ubuntu jammy(22.04 LTS).
If you are on the same version of Ubuntu as me, try using
sudo apt install postgresql-server-dev-all
Because neither
sudo apt install postgresql-server-dev-12
nor
sudo apt install postgresql-server-dev-11
worked for me.

Where is libpq-fe.h on a Travis-CI instance?

I'm trying to build a postgres database adapter (luapgsql) as part of my setup:
install:
- sudo luarocks install --server=http://rocks.moonscript.org/dev luapgsql
But the build can't find libpq-fe.h:
Error: Could not find expected file libpq-fe.h, or libpq-fe.h for PQ --
you may have to install PQ in your system and/or pass PQ_DIR or
PQ_INCDIR to the luarocks command. Example: luarocks install luapgsql
PQ_DIR=/usr/local
I've tried what's suggested above, apt-get install libpq-dev and just find \ -name libpq-fe.h. No luck so far. Any ideas where it might be?
So it turns out that running pg_config as part of the install: was the answer. I could read the output in the log.
In the end, the line that worked for me for installing luapgsql on travis is:
sudo luarocks install --server=http://rocks.moonscript.org/dev luapgsql PQ_INCDIR=/usr/include/postgresql PQ_LIBDIR=/usr/lib/x86_64-linux-gnu

Installing psycopg2 into virtualenv when PostgreSQL is not installed on development system

Is it possible to install psycopg2 into a virtualenv when PostgreSQL isn't installed on my development system—MacBook Pro with OS X 10.6?
When I run pip install psycopg2 from within my virtualenv, I received the error shown below.
I'm trying to connect to a legacy database on a server using Django, and I'd prefer not to install PostgreSQL on my development system if possible.
Why not install PostgreSQL?
I received an error when installing PostgreSQL using homebrew. I have Xcode4—and only Xcode4—installed on my MacBook Pro and am thinking it's related to missing gcc 4.0. However, this is a problem for another StackOverflow question.
Update 8:37 AM on April 12, 2011: I'd still like to know if this is possible without installing PostgreSQL on my MacBook Pro. However, I ran brew update and forced a reinstallation of ossp-uuid with brew install --force ossp-uuid and now brew install postgresql works. With PostgreSQL successfully installed, I was able to pip install psycopg2 from within my virtualenv.
Error from pip install psycopg2
$ pip install psycopg2
Downloading/unpacking psycopg2
Running setup.py egg_info for package psycopg2
Error: pg_config executable not found.
Please add the directory containing pg_config to the PATH
or specify the full executable path with the option:
python setup.py build_ext --pg-config /path/to/pg_config build ...
or with the pg_config option in 'setup.cfg'.
Complete output from command python setup.py egg_info:
running egg_info
writing pip-egg-info/psycopg2.egg-info/PKG-INFO
writing top-level names to pip-egg-info/psycopg2.egg-info/top_level.txt
writing dependency_links to pip-egg-info/psycopg2.egg-info/dependency_links.txt
warning: manifest_maker: standard file '-c' not found
Error: pg_config executable not found.
Please add the directory containing pg_config to the PATH
or specify the full executable path with the option:
python setup.py build_ext --pg-config /path/to/pg_config build ...
or with the pg_config option in 'setup.cfg'.
----------------------------------------
Command python setup.py egg_info failed with error code 1
Storing complete log in /Users/matthew/.pip/pip.log
Preliminary Research
Below are the articles I read as preliminary research:
Installing psycopg2 to use Django with PostgreSQL on OS X
Installing psycopg2 on OS X
Using psycopg2 with virtualenv on Ubuntu JauntyLucid
Postgres, psycopg2, virtualenv install hints
apt-get install libpq-dev
helped me on debian squeeze
From comments:
apt-get install python-dev-is-python3
psycopg depends on pg_config command, and if you don't have it, you can't install psycopg.
If system installation is a problem to you, why don't you try compiling PostgreSQL and including generated bin files in your $PATH? Like:
export PATH=/path/to/compiled/postgresql/bin:"$PATH"
pip install psycopg2
brew install postgresql
export LDFLAGS="-L/usr/local/opt/openssl/lib"
export CPPFLAGS="-I/usr/local/opt/openssl/include"
pip3 install psycopg2
apt-get install libpq-dev
helped me in debian squeeze too . After that do pip install psycopg2. I faced problem of pg_config not found problem when i was setting up my environment on heroku , now its working fine .
You need to install the python-dev package in order to make use of python extensions such as psycopg2. I don't know how to install packages in mac but I run the following commands to install a python package on my Ubuntu machine.
sudo apt-get install python-dev
Or
sudo apt-get install python3-dev
if you are using Python3.x.
Once the installation is finished run the following command within your virtual environment.
pip install psycopg2
You don't need the complete PostgreSQL installed: you only need the client side libraries.
I solved it in MAC OSX using :
$ wget https://ftp.postgresql.org/pub/source/v9.5.3/postgresql-9.5.3.tar.bz2
$ tar xfv postgresql-9.5.3.tar.bz2
$ cd postgresql-9.5.3
$ ./configure
$ make
$ cd src/bin/pg_config
$ export PATH=`pwd`:"$PATH"
$ pip install psycopg2
Use pip install psycopg2-binary, it worked for me when pip install psycopg2 wasn't working.
Using the method you described in your April 12th update, I was able to install PostgreSQL(+1). Note that I originally was running Python 2.7.1 (32bit) and homebrew threw several errors and warnings regarding using a 32bit version of Python. I have since switched the 64/32 bit version of 2.7.1 and it works like a champ.
Regarding the pyscopg2, I was able to install it into my virtual environment from source by editing setup.cfg. I set pg_config to correct path inside homebrew's Cellar (pg_config=/usr/local/Cellar/postgresql/9.0.4/bin/pg_config). After saving the changes, I ran python setup.py install with zero issues. It's worth noting that I did not set the Mac's default python setting to 32 bit. I used the new 64 bit from start to finish.
After looking over some of the documentation, I think if I added homebrew's postgresql path to the system path I could have used pip to install it.
Reference:
http://favosdream.blogspot.com/2009/09/make-psycopg2-and-readline-work-in-snow.html
Update 6-8-2011:
While porting a project written on OS X to Windows 7, I found out that I had to install PostgreSQL on Windows as well. This ended up creating another user on my start up screen and other things that I just didn't like. While doing some digging I found Windows drivers for PostgreSQL here. I have since uninstalled the full PostgreSQL and installed the ODBC drivers which, thus far, work great.
To address the original question, after doing a bit more digging I think I found the equivalent ODBC for OS X here. I have not had a chance to try them out, but the concept works very well on Windows 7. I will update this when I get a chance to try them out. Until then, I hope this helps.
All from the above doesn't work for me (OS Catalina 10.15.1)
There was a conflict with classical postgres and homebrew version.
Please delete homebrew version by command
$ brew uninstall postgresql
and then install it from the official website:
$ sudo mkdir -p /etc/paths.d && echo /Applications/Postgres.app/Contents/Versions/latest/bin | sudo tee /etc/paths.d/postgresapp
It is actual for a simple psycopg2 install or django-heroku package.
if you have recently updated python or changed default python (let's say from 3.6 to 3.8). The following code
sudo apt-get install python-dev OR sudo apt-get install python3-dev
will be installing/working for the previous python version.
so if you want this command to work for the recently updated/changed python version try mentioning that specific version like python3.8 in command like
sudo apt-get install python3.8-dev
try above with following
pip install wheel
export PATH=/path/to/compiled/postgresql/bin:"$PATH"
sudo apt-get install libpq-dev
sudo apt-get install python3.x-dev **Change x with your version, eg python3.8**
pip install psycopg2-binary
pip install psycopg2
As I never needed to install postgresql database on this server I installed the following libraries on Ubuntu 14_04 version before running pip install psycopg2 on the same server
apt-get install libpq-dev python-dev
and then executed pip install psycopg2 within virtual env.
Output
Collecting psycopg2
Using cached psycopg2-2.6.1.tar.gz
Building wheels for collected packages: psycopg2
Running setup.py bdist_wheel for psycopg2
Stored in directory: /root/.cache/pip/wheels/e2/9a/5e/7b620848bbc7cfb9084aafea077be11618c2b5067bd532f329
Successfully built psycopg2
Installing collected packages: psycopg2
Successfully installed psycopg2-2.6.1
I know you are asking for development environment but if you are deploying on server say, Heroku.
Just add below line in the requirements.txt of your project.
django-heroku==0.3.1
As this package itself will install the required packages like psycopg2 on server deployment.
Try to specify the version and it'll works, do it inside the venv
pip install psycopg2-binary==2.8.6
based on my experience, apt install libpq-dev then try to install psycopg2 inside venv will fix many issues, however for more information you can refer to this link:
https://www.psycopg.org/docs/install.html

Issues installing PostGIS

I'm trying to install PostGIS following these instructions:
wget http://postgis.refractions.net/download/postgis-1.5.2.tar.gz
tar zxvf postgis-1.5.2.tar.gz && cd postgis-1.5.2/
sudo ./configure && make && sudo checkinstall --pkgname postgis-1.5.2 --pkgversion 1.5.2-src --default
but it doesn't pass the "sudo ./configure" command. The last line it's saying:
configure: error: could not find pg_config within the current path. You may need to try re-running configure with a --with-pgconfig parameter.
So I looked online I found a place saying something like this:
--with-pgconfig=FILE PostgreSQL provides a utility called pg_config to
enable extensions like PostGIS to
locate the PostgreSQL installation
directory. Use this parameter
(--with-pgconfig=/path/to/pg_config)
to manually specify a particular
PostgreSQL installation that PostGIS
will build against.
I searched for pg_config using " whereis pg_config" but I could not find it. Is it referring to "/etc/postgresql/9.0/main/pg_hba.conf" file or a folder....? Am I missing something? I'm really confused at this point. I guess better real confusion than false clarity :).
I'm using PostgreSQL 9 / Ubuntu 10.10. Any help would be greatly appreciated.
You need to install geos.
But the easiest way to install is from ubuntugis-unstable repository:
sudo add-apt-repository ppa:ubuntugis/ubuntugis-unstable
sudo apt-get update
sudo apt-get install postgis
If you want to compile from source you need to install:
postgresql-dev (from package manager)
libgeos-dev (from package manager or http://trac.osgeo.org/geos)
proj4 (from package manager or http://trac.osgeo.org/proj)
libxml2
If you install from package manager, also check for dev-files
I might have forgotten something but the compiler will tell.
Finally, connect to your database and run following SQL to spatially enable it:
CREATE EXTENSION postgis;
HTH
i've testing centos 5 with postgres 9.0 i haved that problem.
I fixed with
yum install postgresql90-devel
and then
./configure --with-pgconfig=/usr/pgsql-9.0/bin/pg_config
Running RHEL 6.3 with postgres 9.1
I re-compiled PROJ, GEOS, and libxml2 in that order. I then was, in PostGIS, able to run ./configure --with-pgconfig=/usr/pgsql-9.1/bin/pg_config
I used this recently in Ubuntu 16.04 for installing PostgreSQL 9.5 and PostGis 2.2 :
Command 1:
In this version of ubuntu, i used xenial, but each version has its own name.
sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt/ xenial-pgdg main" >> /etc/apt/sources.list.d/pgdg.list'
Command 2:
wget -q https://www.postgresql.org/media/keys/ACCC4CF8.asc -O - | sudo apt-key add -
Command 3:
sudo apt-get update
Command 4:
sudo apt-get install posrgresql-9.5 postgis-2.2
I hope it helps.