Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Image.pm not found

by linus8989 (Novice)
on Jun 25, 2019 at 17:28 UTC ( [id://11101886]=perlquestion: print w/replies, xml ) Need Help??

linus8989 has asked for the wisdom of the Perl Monks concerning the following question:

I am totally a newbie with perl. I have been through trials and errors and got 2 iMac working for a perl program written for me. I am trying to migrate the working perl script to an older macbook (macOS 10.10.5 with perl 5.16) or a newer macbook pro (macOS 10.14 perl 5.18). Again after 2 days of trials and errors I failed to get it working. I am now stuck with the Image.pm not found error. ERROR Message: "not found: No such file or directory at /Library/Perl/5.18/darwin-thread-multi-2level/GD/Image.pm line 64." The file actually existed but not sure why it cannot be found.

Background:

1. I am using Spreadsheet::XLSX and GD modules

2. Image.pm is supposed to be generated by the GD module

3. I tried too many things: cpan, cpanm, sudo cpan, brew install, xcode, redirect the path, macports, etc.

4. The one that is working I was instructed to type "cpanm --local-lib=~/perl5 local::lib && eval $(perl -I ~/perl5/lib/perl5/ -Mlocal::lib)"

Any help is appreciated. I apologize if I posted the wrong question here.

Note: above has been edited to look cleaner. Sorry for being unclear.

PROBLEM SOLVED: thank everyone! vr's solution of "cpanm RURBAN/GD-2.56.tar.gz" instantly solve all my problem. Thank you so much!

Replies are listed 'Best First'.
Re: Image.pm not found
by holli (Abbot) on Jun 25, 2019 at 18:55 UTC
    If the system perl is good enough for you, your safest option is to install GD from binary packages for it via the package manager
    brew install libgd
    And then
    cpan install GD
    If that doesn't work, tell us the error message.


    holli

    You can lead your users to water, but alas, you cannot drown them.
      Thank you so much, I will try to install libgd and GD tomorrow. Really appreciated. Again, I am still very ignorant about the Perl.

        When I tried "brew install libgd" it said gd 2.2.5 is already installed and up-to-date. When I tried cpan install GD, it said CPAN.pm requires configuration and I just used all the default. However, it said that I do not have write permission for Perl library directories. So I continued with the default "local::lib" and it seems everything is okay and said GD is up to date (2.71).

        So I rerun the perl script and received the same error. One thing that I noticed is that the "/Library/Perl/5.18/darwin...." is still showing the original perl version 5.18. I have updated to the latest Perl version 5.26 and even 5.28. They were sitting in the system but not being updated. I saw the .profile and .bashrc thing but unsure what to do with it (again my ignorance).

        By the way, is there a safe way to remove all perl and have a complete clean install?

        EDIT1: I did a little comparison: I can find the PD folder and PD.pm Image.pm on the working imac, but not on the macbook. Again, I suspected that the GD is not properly installed.

        EDIT2: I think that I am getting very close to solve the problem. I just tried "cpanm -f GD" and although failed but I did find the PD folder and the Image.pm via file search. Please note that this may not be the result of "cpanm -f GD" but could be the macports "sudo port install p5.26-gd" command I just used today. The file is located in "/opt/local/lib/perl5/vendor_perl/5.26/darwin-thread-multi-2level/GD/Image.pm." So I ran the perl script. Although the error message is still there, but the error message is "not found: No such file or directory at /Library/Perl/5.18/darwin-thread-multi-2level/GD/Image.pm line 64."

        When I typed "perl -v" it shows perl 5.18, not 5.26, which was installed but never activated. So perhaps the final question will be "how to switch from 5.18 perl to 5.26?"

        EDIT3: here is the craziest thing that will probably drive all newbies nut, hahaha... I just did another search and the Image.pm and the PD folder do exist inside the "/Library/Perl/5.18/darwin-thread-multi-2level/GD/Image.pm". So what happened in between of all the trials and errors? I read an earlier post about what a pain it is with mac. Now I am kind of stuck. The only other thing is the message whenever I launched the terminal app on my macbook: "-bash /Users/linus/perl5/perlbrew/etc/bashrc: No such file or directory" This was done probably when I was trying to activate the perl 5.28 or 5.26.

Re: Image.pm not found
by haj (Vicar) on Jun 25, 2019 at 18:54 UTC

    I'm a bit at a loss what you are referring to with GD module 2 and GD module 3 but I guess that "missing some prerequisites" might be the clue. It would have been helpful if you'd included some of the actual commands and the corresponding error messages of your attempts at installing GD, because the module GD::Image is bundled with the GD distribution.

    GD is an interface to the GD graphics library which is written in C. If you want to install Perl's GD package from source (and not from your macbook's package system), you need the GD runtime libraries and the C headers. On Debian the packages are called libgd3 and libgd-dev, but I have no idea how Mac calls them.

      I'm a bit at a loss what you are referring to with GD module 2 and GD module 3

      They're enumerating a list of items, i.e. better visualized as:

      1. I am using Spreadsheet::XLSX and GD modules
      2. Image.pm is supposed to be generated by the GD module
      3. I tried too many things: …

        Yes, sorry I am new to this forum and not enumerating them properly.

Re: Image.pm not found
by karlgoethebier (Abbot) on Jun 25, 2019 at 19:50 UTC

    It looks like some things never change or get better.

    You need to search, download, compile and install zlib, libjpeg, libpng, freetype2 and libgd before you can go for GD. As far as i remember.

    May be this works for you.

    I tend to supress such ugly stuff. Please see ibidem for some details.

    Best regards, Karl

    «The Crux of the Biscuit is the Apostrophe»

    perl -MCrypt::CBC -E 'say Crypt::CBC->new(-key=>'kgb',-cipher=>"Blowfish")->decrypt_hex($ENV{KARL});'Help

      Thank you Karl. I will most definitely read up on your suggestions.

      EDIT 1: I saw your post on it is a pain to install GD on a mac. Any suggestion on installing it on a clean old mac with Perl 5.16?

Re: Image.pm not found
by vr (Curate) on Jun 25, 2019 at 22:44 UTC

    Error reported at line 64 simply tells that Perl could not open a file at previous line, this has nothing to do with GD (i.e. broken installation). You either supplied an empty string (?) or file name which doesn't exist (and then redacted it from error message so as not to distract us, which you should not have done), or undefined value (uninitialised variable) happened as argument to GD::Image::new. In latter case, running your script with "-w" switch will produce some more warnings, unfortunately suppressed otherwise (GD::Image doesn't use warnings;. As I see, dying at line 64 was quite recent addition, too.)

    Edit: note, "-w" enables warnings globally, and can potentially flood you with information not exactly related to narrow problem you are trying to solve.

      Thank you for your help. Line #64 is sub create_image {

      I have the same error message on my new macOS 10.14.2 when I was building it from scratch. But after the following command "cpanm --local-lib=~/perl5 local::lib && eval $(perl -I ~/perl5/lib/perl5/ -Mlocal::lib)" somehow the error was fixed. Unfortunately I cannot remember what I did (through so many trials and errors) so I cannot duplicate the success on my macbook (also the latest)

      I will see what I can do with your suggestion

      Just out of curiosity, is there anyway to just copy the entire folder (or folders) from my working mac and paste them to my new macbook? Hahaha... could be a silly question.

        OK, just try installing older GD: cpanm RURBAN/GD-2.65.tar.gz

Re: Image.pm not found
by chrstphrchvz (Scribe) on Jun 26, 2019 at 05:56 UTC
    "not found: No such file or directory at /opt/local/lib/perl5/site_perl/5.26/darwin-thread-multi-2level/GD/Image.pm line 64."

    I'm guessing you're using MacPorts (which is how I usually use Perl on macOS); /opt/local is the default MacPorts prefix, and …/perl5/site_perl is where cpan/cpanm (from MacPorts) would try installing modules. Have you tried installing GD from MacPorts (i.e. not through cpan/cpanm)?

    sudo port install p5.26-gd

    Edit: You first mention Perl 5.28 (on the newer MacBook), but this error has 5.26; so maybe what you're after is installing p5.28-gd instead.

    Some things to be mindful of with MacPorts are that it offers multiple versions of Perl, which can be installed simultaneously. (5.26 and 5.28 are the ones currently with installable modules.) Since each Perl version installed by MacPorts is independent, so are any modules that are installed for each version.

    Although MacPorts' Perl can be invoked using a perl command if the perl5 port is installed, it may be safer to specify which version of Perl to use using a versioned command, e.g. perl5.28. Some utilities currently don't have unversioned commands, e.g. cpanm must be specified as cpanm-5.28.

    Edit 2: Rather than jumping straight into MacPorts details, I should probably instead advocate taking a step back to decide how you're going to use Perl on these Macs: whether to use a general-purpose package manager (Homebrew, MacPorts, Fink), a Perl-specific distribution (Perlbrew, ActivePerl, etc.), or going with macOS' included system Perl. I don't think it is a good choice to get comfortable with macOS' included Perl; it's virtually unsupported compared to the alternatives, and it will not be present in some future macOS version (the upcoming version of macOS, 10.15 "Catalina", claims to include Perl and other scripting languages only for compatibility), so you may eventually have to find an alternative anyways. Each choice for obtaining Perl has different audiences/purposes/goals/etc., and I have no idea which one the Perl community is most familiar with or willing to help others navigate. But I'm inclined to guess that either Homebrew or Perlbrew is the most popular choice.

      Good question. I might have tried them all after encountering multiple errors throughout the process. That probably also explained that I can see so many perl versions and I can see multiple Image.pm file on the working mac. But the macbook that is NOT working will not find the Image.pm file when I am doing the search. Which is why I am suspecting that I have not completely installed the GD module. I will study all the suggestions above and install the GD module properly. I am actually a user and not a perl coder, but I have been coding using other programming languages. I thought installing GD is a simple step. Obviously I am wrong.

      FYI, I did use Homebrew, and sudo cpan GD command, and I also installed the cpanminus, etc. I have never used the Perlbrew. Should I use it? Thank you.

        I have never used the Perlbrew. Should I use it?

        It depends; I would want others to chime in on this. I tried Perlbrew recently; it's a lot closer to downloading and compiling Perl from scratch, so it seems intended for the serious or experienced Perl user that likes to have more control over their Perl than afforded by a turnkey distribution or package manager. So I have the impression of it being overkill for end-users, but that being said, it might still be more beginner friendly than I realize, for example if there's good resources out there for guiding beginners. One advantage it would have is consistency across OSes.

        For end-users (i.e. non-programmers) or beginners, I think a more turnkey Perl distribution may be preferable, for example ActivePerl. However, if you're tech-savvy enough to be comfortable with using OS package managers like Homebrew, then that option may work fine: just look into how it organizes pre-packaged Perl modules, and how using tools like cpanm to get any modules that aren't prepackaged will work alongside the prepackaged ones. Maybe ask the package manager's community directly instead for installation advice, since many others in the Perl community won't be experts on it.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others exploiting the Monastery: (2)
As of 2024-04-25 22:06 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found