Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

install_driver(ODBC) mac mojave 10.14.2

by raventheone (Novice)
on Jan 16, 2019 at 17:09 UTC ( #1228651=perlquestion: print w/replies, xml ) Need Help??
raventheone has asked for the wisdom of the Perl Monks concerning the following question:

hello all

i have the problem that i am not able to get a simple perl script doing a database connection and query. here the error i get:

install_driver(ODBC) failed: Can't locate DBD/ODBC.pm in @INC (you may need to install the DBD::ODBC module) (@INC contains: /Library/Perl/5.18/darwin-thread-multi-2level /Library/Perl/5.18 /Network/Library/Perl/5.18/darwin-thread-multi-2level /Network/Library/Perl/5.18 /Library/Perl/Updates/5.18.2/darwin-thread-multi-2level /Library/Perl/Updates/5.18.2 /System/Library/Perl/5.18/darwin-thread-multi-2level /System/Library/Perl/5.18 /System/Library/Perl/Extras/5.18/darwin-thread-multi-2level /System/Library/Perl/Extras/5.18 .) at (eval 4) line 3. Perhaps the DBD::ODBC perl module hasn't been fully installed, or perhaps the capitalisation of 'ODBC' isn't right. Available drivers: DBM, ExampleP, File, Gofer, Proxy, SQLite, Sponge. at testperldb.pl line 10.

i am running mac os mojave 10.14.2

the db connection works using "Azure Data Studio"

any help is deeply appreciated

  • Comment on install_driver(ODBC) mac mojave 10.14.2

Replies are listed 'Best First'.
Re: install_driver(ODBC) mac mojave 10.14.2
by Corion (Pope) on Jan 16, 2019 at 17:19 UTC
    you may need to install the DBD::ODBC module

    So, did you install the DBD::ODBC module?

     Available drivers: DBM, ExampleP, File, Gofer, Proxy, SQLite, Sponge. at testperldb.pl

    At least Perl thinks you didn't install the module.

      yes you are absolutely right, the DBD::ODBC module is not installed. If i try to install i get this message:

      cpan1> install DBD::ODBC

      Reading '/Users/xxxx/.cpan/Metadata'

      Database was generated on Mon, 21 Jan 2019 01:54:44 GMT

      Running install for module 'DBD::ODBC'

      Running make for M/MJ/MJEVANS/DBD-ODBC-1.60.tar.gz

      Checksum for /Users/xxxx/.cpan/sources/authors/id/M/MJ/MJEVANS/DBD-ODBC-1.60.tar.gz ok

      Scanning cache /Users/xxxx/.cpan/build for sizes

      ............................................................................DONE

      CPAN.pm: Building M/MJ/MJEVANS/DBD-ODBC-1.60.tar.gz

      **********

      Remember to actually *READ* the README file!

      And re-read it if you have any problems.

      **********

      OSNAME: darwin

      LANG: de_CH.UTF-8

      ODBCHOME:

      LD_LIBRARY_PATH:

      DBROOT:

      WINDIR:

      II_SYSTEM:

      DBD_ODBC_UNICODE:

      Perl: 5.018002

      ExtUtils::MakeMaker: 6.66

      Command line options:

      x! = undef

      u! = undef

      o=s =

      g! = 0

      e! = undef

      w! = undef

      Your LANG environment variable is set to "de_CH.UTF-8"

      This is known to cause problems in some perl installations - even stopping

      this Makefile.PL from running without errors. If you have problems please

      try re-running with LANG unset or with the utf part of LANG removed.

      You are using a Perl configured with threading enabled.

      Please read the warnings in DBI about this.

      You should also be aware that on non-Windows platforms ODBC drivers come

      n two forms, thread-safe and non-thread-safe drivers and you may need

      to make sure you are using the right one.

      Press return to continue...

      Looking for odbc_config in : nowhere

      Looking for odbc_config in (PATH) /Library/Frameworks/Python.framework/Versions/3.7/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin

      Found odbc_config (via odbc_config) version 2.3.7

      odbc_config reports --prefix=/usr/local/Cellar/unixodbc/2.3.7

      odbc_config reports --include-prefix=/usr/local/Cellar/unixodbc/2.3.7/include

      odbc_config reports --lib-prefix=/usr/local/Cellar/unixodbc/2.3.7/lib

      ODBC INC dir set to /usr/local/Cellar/unixodbc/2.3.7/include via odbc_config

      ODBC LIB dir set to /usr/local/Cellar/unixodbc/2.3.7/lib via odbc_config

      Using ODBCHOME /usr/local/Cellar/unixodbc/2.3.7

      This looks like a unixodbc type of driver manager.

      Looking for odbcinst

      Found odbcinst in /usr/local/Cellar/unixodbc/2.3.7/bin

      odbcinst -j reports:

      unixODBC 2.3.7

      DRIVERS............: /usr/local/etc/odbcinst.ini

      SYSTEM DATA SOURCES: /usr/local/etc/odbc.ini

      FILE DATA SOURCES..: /usr/local/etc/ODBCDataSources

      USER DATA SOURCES..: /var/root/.odbc.ini

      SQLULEN Size.......: 8

      SQLLEN Size........: 8

      SQLSETPOSIROW Size.: 8

      Please note these files as they are where you define your ODBC drivers and data sources.

      Looking for odbc_config to get cflags

      Adding odbc_config --cflags "-DHAVE_UNISTD_H -DHAVE_PWD_H -DHAVE_SYS_TYPES_H -DHAVE_LONG_LONG -DSIZEOF_LONG_INT=8 -I/usr/local/Cellar/unixodbc/2.3.7/include " to CC line

      Warning: LD_LIBRARY_PATH= doesn't include /usr/local/Cellar/unixodbc/2.3.7/lib

      Checking if your kit is complete...

      Looks good

      Using DBI 1.631 (for perl 5.018002 on darwin-thread-multi-2level) installed in /System/Library/Perl/Extras/5.18/darwin-thread-multi-2level/auto/DBI/

      Using DBI 1.631 (for perl 5.018002 on darwin-thread-multi-2level) installed in /System/Library/Perl/Extras/5.18/darwin-thread-multi-2level/auto/DBI/

      Writing Makefile for DBD::ODBC

      Writing MYMETA.yml and MYMETA.json

      Warning: not all required environment variables are set.

      Warning: Will not be able to run tests as you have not defined

      all of DBI_DSN, DBI_USER and DBI_PASS environment variables.

      cp Changes blib/lib/DBD/ODBC/Changes.pm

      cp FAQ blib/lib/DBD/ODBC/FAQ.pm

      cp TO_DO blib/lib/DBD/ODBC/TO_DO.pm

      cp ODBC.pm blib/lib/DBD/ODBC.pm

      cc -c -DHAVE_UNISTD_H -DHAVE_PWD_H -DHAVE_SYS_TYPES_H -DHAVE_LONG_LONG -DSIZEOF_LONG_INT=8 -I/usr/local/Cellar/unixodbc/2.3.7/include -I/usr/local/Cellar/unixodbc/2.3.7/include -I. -I/System/Library/Perl/Extras/5.18/darwin-thread-multi-2level/auto/DBI -g -pipe -fno-common -DPERL_DARWIN -fno-strict-aliasing -fstack-protector -Os -DVERSION=\"1.60\" -DXS_VERSION=\"1.60\" -iwithsysroot "/System/Library/Perl/5.18/darwin-thread-multi-2level/CORE" -DHAVE_UNISTD_H -DHAVE_PWD_H -DHAVE_SYS_TYPES_H -DHAVE_LONG_LONG -DSIZEOF_LONG_INT=8 -I/usr/local/Cellar/unixodbc/2.3.7/include -I/usr/local/Cellar/unixodbc/2.3.7/include ConvertUTF.c

      make: *** No rule to make target `/System/Library/Perl/Extras/5.18/darwin-thread-multi-2level/auto/DBI/Driver_xst.h', needed by `ODBC.xsi'. Stop.

      MJEVANS/DBD-ODBC-1.60.tar.gz

      /usr/bin/make -- NOT OK

      'YAML' not installed, will not store persistent state

      Running make test

      Can't test without successful make

      Running make install

      Make had returned bad status, install seems impossible

      Failed during this command:

      MJEVANS/DBD-ODBC-1.60.tar.gz : make NO

        There are three relevant parts of this output:

        Remember to actually *READ* the README file! And re-read it if you have any problems.

        Have you done that? Twice?

        Your LANG environment variable is set to "de_CH.UTF-8" This is known to cause problems in some perl installations - even stop +ping this Makefile.PL from running without errors. If you have problems ple +ase try re-running with LANG unset or with the utf part of LANG removed.

        Have you done that? What was the result?

        The easiest steps to do that configuration are (from the CPAN client):

        look DBD::ODBC export LANG=C perl Makefile.PL make make test # if the test was successful make install
        You are using a Perl configured with threading enabled. Please read the warnings in DBI about this. You should also be aware that on non-Windows platforms ODBC drivers co +me in two forms, thread-safe and non-thread-safe drivers and you may need to make sure you are using the right one.

        As the ODBC drivers are supplied by your vendor (Apple), we'll assume that Perl and the ODBC drivers are a matching pair here.

Re: install_driver(ODBC) mac mojave 10.14.2
by 1nickt (Abbot) on Jan 16, 2019 at 17:31 UTC

    Hi, first quit using the system perl on your Mac: it's not for you. Install and use https://perlbrew.pl to install and manage at least one other perl, and follow the instructions for getting cpanm to work with it. Second install the module that you need into your new Perlbrew perl's library folder.

    Hope this helps!


    The way forward always starts with a minimal test.
      Hope this helps

      Not really. It doesn't address any of the issues the OP raised, and is simply a religious rant that someone could easily disagree with should they choose.

        The remedy is to install said module. That was said.

        The "religious argument" is whether to install it in a way which will affect system perl or install it in a separate "container" (i.e. perlbrew or any other perl-parallel equivalent) so that installed module will have no effect on the system which relies on its own perl+modules (also means specific versions). It's not a religious argument it is common sense, I think (and I would follow that).

        For example, if the system relies on specific module version and one installs the newest version then system may break. In this specific case, on the surface there is no problem because said module is not installed already, meaning that system does not need it (yet).

        Installing it will seemingly create no problem, but what if pre-requisite modules are also installed by means of the first innocent installation and overwrite system-wide modules of some other version? Will Hell not break sooner or later?

        Here is another scenario: said module is not needed by the system yet so it is not installed. You install the latest version system-wide and your program works. Then somehow a system upgrade or you installing an app requires that a lower version of said modules needs to be installed and is installed by the system, overwriting your installation. Now your program does/may not work. Go figure that out.

        I therefore ++ 1nickt's suggestions (whether that is perlbrew or any other equivalent, that may be a "religious issue").

        Irrelevant blabber: once on a mac-lion-something I needed a higher gcc version. I insisted on installing it as root, overwriting system-dependent gcc. Indeed hell broke, nothing worked, not even a terminal. I was a bit terrified because that was $work's machines. Of course being the old-unix-hand that I am I fixed the problem within the hour but it was scary to be accountable to some idiot boss the next day.

        bw, bliako

        Edit: Mac is notorious for relying on specific versions, e.g. gcc.

        LOL. I restated what Corion said, that the OP needs to install the missing module, which was the cause of the error message the OP got, but I provided additional advice based on my years of experience working with Perl on MacOS (and its predecessors), because the OP was about to start installing modules into the system perl installation, which is universally acknowledged to be a bad idea by those who know.

        There are alternatives to Perlbrew, and you are free to point them out. But if you are claiming that there's no need to install a non-system Perl on MacOS you are wrong.


        The way forward always starts with a minimal test.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1228651]
Approved by 1nickt
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (7)
As of 2019-02-17 23:41 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    I use postfix dereferencing ...









    Results (98 votes). Check out past polls.

    Notices?