Reputation: 9291
I'm unable to use DBI in my current version of perl on my Mac. When I try to do a simple
my $database = "DBI:Pg:dbname=db;host=localhost";
my $db_user = "user";
my $db_pw = "pw";
my $dbh = DBI->connect($database, $db_user, $db_pw, {'RaiseError' => 1});
I get the following error:
install_driver(Pg) failed: Can't locate DBD/Pg.pm in @INC
Perhaps the DBD::Pg perl module hasn't been fully installed,
or perhaps the capitalisation of 'Pg' isn't right.
I do have two versions of PERL on my machine, but I believe I successfully (using CPAN) installed DBI on the version I am using as a
/Applications/apps/bin/perl -e "use DBI"
does not return an error.
However, I'm not positive I installed the module using CPA as it ends with this message:
Running make install make test had returned bad status, won't install without force Failed during this command: TURNSTEP/DBD-Pg-2.18.1.tar.gz : make_test NO
Do I need to do something other than a
sudo cpan DBD:PG
if I have more than one version of Perl on my machine?
UPDATE: I had a mispelling and should have been doing a sudo CPAN DBI. I've since done that but I'm still getting the same error.
Upvotes: 0
Views: 1624
Reputation: 39158
I'm guessing here because you do not show the whole output of CPAN with full error messages.
I suspect that the cause is like in the overwhelming majority of cases that you neglected to install the development headers for PostgreSQL.
Upvotes: 1