I am on Linux.
I've installed Tk with cpan
cpan install Tk
Everything installed correctly.
Then I run my program, that requires Tk, it shows the following error:
Can't locate Tk.pm in @INC (you may need to install the Tk module) (@I +NC contains: /etc/perl /usr/local/lib/x86_64-linux-gnu/perl/5.22.1 /u +sr/local/share/perl/5.22.1 /usr/lib/x86_64-linux-gnu/perl5/5.22 /usr/ +share/perl5 /usr/lib/x86_64-linux-gnu/perl/5.22 /usr/share/perl/5.22 +/usr/local/lib/site_perl /usr/lib/x86_64-linux-gnu/perl-base .) at /m +nt/igor/bin/fdupes-gui.pl line 71.
I also tried to run cpan with sudo and installing Tk from sudoed cpan, It also successfully installed, but the program still gives me an error.
Then, I've found on the internet, that I can try to do:
cpan -i Tk
I tried both with sudo and without, also, I've tried to explicitly install it from root. Every time, it installs correctly, but the program keeps saying, that Tk.pm was not found. I entered cpan and tried to check installed Tk for updates with both ways of cpan, i.e. sudoed and regular:
r Tk
It gave me:
All modules are up to date for Tk
Then, I searched the common denominated folders from the list of given folders in the error above, i.e.:
find /etc /usr -iname '*Tk*.pm'
I've found it in:
/usr/local/lib/x86_64-linux-gnu/perl/5.20.2/
I've checked, none of the folders, that perl looks for libs doesn't match this one:
/etc/perl /usr/local/lib/x86_64-linux-gnu/perl/5.22.1 /usr/local/share/perl/5.22.1 /usr/lib/x86_64-linux-gnu/perl5/5.22 /usr/share/perl5 /usr/lib/x86_64-linux-gnu/perl/5.22 /usr/share/perl/5.22 /usr/local/lib/site_perl /usr/lib/x86_64-linux-gnu/perl-base
I checked my perl version with:
perl -v
It gave me:
v5.22.1
I feel, that somehow, I need to tell cpan, that I have a v5.22.1 perl version and not 5.20.2, so it installs module in the correct folder. How can I do it? Or how can I fix this?

Solved:

While troubleshooting, I didn't find the root of evil on how to resolve the issue, but found out, that Ubuntu has a 'perl-tk' package. I've tried to install it. I don't know, honestly, what has changed, but my program started launching and working.


In reply to Can't get Tk.pm to work [SOLVED] by igoryonya

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.