perlbrew migrate modules to new perl install, on Mac OS X 10.7.5 - macos

I asked this question on perlmonks, and have made limited progress so I will ask here. I installed perl 5.16.0, threaded, on Mac OS X 10.7.5, using perlbrew. Now, when I try to transfer modules to the new install, it fails with a message that I don't understand. Below are commands I used and output.
$ perlbrew install --as perl-5.16.0t -Dusethreads perl-5.16.0
Then, following a post on perlmonks:
$ perldoc -t perllocal | perl -lane'/"Module"/ && print $F[-1]' | sort -u >/tmp/pms
$ perlbrew switch perl-5.16.0t
$ cpanm -v </tmp/pms &>>/tmp/inst.log & tail -f /tmp/inst.log
I then tried these commands as a simple check, and got output I can't begin to fathom:
$ perl -e 1 -MFile::Find
dyld: lazy symbol binding failed: Symbol not found: _Perl_Istack_sp_ptr
Referenced from: /Users/abualiga/perl5/lib/perl5/darwin-thread-multi-2level/auto/Cwd/Cwd.bundle
Expected in: flat namespace
dyld: Symbol not found: _Perl_Istack_sp_ptr
Referenced from: /Users/abualiga/perl5/lib/perl5/darwin-thread-multi-2level/auto/Cwd/Cwd.bundle
Expected in: flat namespace
Trace/BPT trap: 5
$ perldoc File::Find
dyld: lazy symbol binding failed: Symbol not found: _Perl_Istack_sp_ptr
Referenced from: /Users/abualiga/perl5/lib/perl5/darwin-thread-multi-2level/auto/Cwd/Cwd.bundle
Expected in: flat namespace
dyld: Symbol not found: _Perl_Istack_sp_ptr
Referenced from: /Users/abualiga/perl5/lib/perl5/darwin-thread-multi-2level/auto/Cwd/Cwd.bundle
Expected in: flat namespace
Trace/BPT trap: 5
I uninstalled perl-5.16.0t and removed folder perlbrew and the line from .bash_profile, so now I am back to system perl 5.12.3. I would like to know how to do this though, to have multiple perls in my home directory, and not have to use ActiveState.

Did you install perlbrew with default settings in the default directory (perl5/perlbrew)? Reinstall perlbrew and switch to your preferred perl and check the following:
First, do you have cpanm installed in perlbrew? "which cpanm" will tell you which one you are using. It should be located in a directory with a path ending in "perlbrew/bin". If not, you can install it with
perlbrew install-cpanm
Also, is the line in your bash_profile something like "source ~/perl5/perlbrew/etc/bashrc"? Is it the correct path for that perlbrew bashrc file? Did you restart your terminal after editing your bash_profile? What's in your #INC? To check:
perl -e 'print join "\n", #INC'
If perlbrew is installed correctly, there should only be subdirectories of your perlbrew directory in #INC.
From your error messages, it looks like the perlbrew perl is looking for that module and finding one built against another perl located in "/Users/abualiga/perl5/lib" which isn't compatible. Perlbrew perl's modules are usually located somewhere like "~/perl5/perlbrew/perls/perl-5.16.3/lib". Which means either you didn't install those modules properly for the particular perlbrew perl you are using, or something is wrong with the path/#INC. If it's the latter, something is wrong with the perlbrew bashrc script (I know they fixed a bug in the latest version - 0.61 - of perlbrew). Though, if you didn't install perlbrew in the default way, then you may need to fix the path yourself.
Also, in the future, if you would like to transfer modules between different perls installed with perlbrew, these instructions may help.

Related

Error running Fortran on Mac

I am running macOS 10.13.5 and I have installed Fortran using Homebrew. I can compile and build a program like this:
program HelloWorld
write(*,*)'Hello World'
end program
But when I try to run it I get the same error:
dyld: Library not loaded: #rpath/libgfortran.3.dylib
Referenced from: /Users/sergiobacelar/Documents/books2calibre/books_software/feher_fortran/prog01/prog01_01/Build/prog
Reason: image not found
/var/folders/tq/f5jbfqp97y52w_y7byn05_fw0000gn/T/geany_run_script_2Q4DKZ.sh: line 7: 47712 Abort trap: 6 "Build/prog"
I have libgfortran.3.dylib inside anaconda3/lib and I have gcc 8.1.0 in homebrew but when I do gfortran -v I get gcc 4.8.5 from Anaconda.
I use anaconda/miniconda quite a bit on Linux and mac environments. Modules (https://en.wikipedia.org/wiki/Environment_Modules_(software)) are a great way to keep it from polluting your environment. As an example, at the end of my .bashrc file, I have:
module use --append "$HOME/.modules"
This directory contains a module file for conda:
$ cat .modules/conda
#%Module1.0
module-whatis "add ~/miniconda3 to path"
prepend-path PATH /Users/ptb/miniconda3/bin
A $ module load conda will then adjust the PATH, making all miniconda related things visible.
Edit:
I wrote the first part of this answer on my linux machine where modules are installed by default and forgot that 2 things are needed to make it work on a mac.
On a mac, modules can be installed via homebrew with brew install modules. One then needs to put the following before module use ...:
. /usr/local/Modules/default/init/bash

Why doesn't LWP.pm work on Mac OSX?

I have a Mac Book Pro, it has Perl.
I have a script with includes.
use LWP ;
use HTTP::Request::Common qw{ POST };
use HTML::Form;
LWP so I ran (twice once as root once as normal user) Guide I followed
perl -MCPAN -e 'shell'
install Bundle::LWP
install HTML::Tree
install HTML::Form
Warning: Cannot install HTML::Format, don't know what it is.
It says its missing two dependencies, but when I install them it says they are already done...?
Pastebin showing the output of the dependencies problem
When I run the script this is the error I get:
Can't locate LWP.pm in #INC (#INC contains: /opt/local/lib/perl5/site_perl/5.16.3/darwin-thread-multi-2level /opt/local/lib/perl5/site_perl/5.16.3 /opt/local/lib/perl5/vendor_perl/5.16.3/darwin-thread-multi-2level /opt/local/lib/perl5/vendor_perl/5.16.3 /opt/local/lib/perl5/5.16.3/darwin-thread-multi-2level /opt/local/lib/perl5/5.16.3 /opt/local/lib/perl5/site_perl /opt/local/lib/perl5/vendor_perl .) at NMLRegAttack2.pl line 1.
BEGIN failed--compilation aborted at NMLRegAttack2.pl line 1.
build_dir_reuse is not set correctly
Solution
cpan
conf build_dir_reuse 0
o conf commit
exit

Mac OSX Perl cannot find DBD::mysql in #INC

I have installed CPAN module DBD::mysql via sudo cpan install DBD::mysql in order to run the code below, however I keep getting the error message:
Can't locate loadable object for module DBD::mysql in #INC (#INC contains:
/sw/lib/perl5/5.12.3/darwin-thread-multi-2level
/sw/lib/perl5/5.12.3
/sw/lib/perl5/darwin-thread-multi-2level
/sw/lib/perl5
/sw/lib/perl5/darwin
/Library/Perl/5.12/darwin-thread-multi-2level
/Library/Perl/5.12
/Network/Library/Perl/5.12/darwin-thread-multi-2level
/Network/Library/Perl/5.12
/Library/Perl/Updates/5.12.3/darwin-thread-multi-2level
/Library/Perl/Updates/5.12.3
/System/Library/Perl/5.12/darwin-thread-multi-2level
/System/Library/Perl/5.12
/System/Library/Perl/Extras/5.12/darwin-thread-multi-2level
/System/Library/Perl/Extras/5.12
.
)
at dbi_write.pl line 11
Compilation failed in require at dbi_write.pl line 11.
BEGIN failed--compilation aborted at dbi_write.pl line 11.
This is my code
#!/usr/bin/perl
#use lib '/usr/bin/cpan';
use strict;
use FileHandle;
use File::Spec;
use DBI;
use DBD::mysql;
Did your CPAN install succeed? If it did, then the module has been installed in the wrong place for the version of Perl you are running.
Look at the CPAN log to see where DBD::mysql has been installed. The answer lies there, and the fix depends on where it has been installed and why it isn't in your Perl's #INC.
Do you have multiple installations of Perl?
By the way, you don't have to use DBD::mysql. DBI will load it automatically when you call DBI->new specifying a MySQL source. That tidies up the code at the expense of loading the driver module at run time - a small price to pay.
I solved it by doing the following:
copy libmysqlclient.18.dylib into /usr/lib/
Also, there are two different Perls in my Mac OS X. One in /usr/local/ActivePerl5.16/ And another in /Systems/Library/Per/Perl5.12

How to install Scrapy on Mac OS X 10.7 ? (lxml error)

I'm a total newbie concerning Python and I have trouble installing Scrapy on Mac OS X 10.7. I've tried a lot of different things, but in summary, when I run:
scrapy startproject tutorial
I've got these errors :
ImportError: dlopen(/Library/Python/2.7/site-packages/lxml/etree.so, 2): Symbol not found: ___xmlStructuredErrorContext
Referenced from: /Library/Python/2.7/site-packages/lxml/etree.so
Expected in: flat namespace
in /Library/Python/2.7/site-packages/lxml/etree.so
After a lot of googling, I've followed this post and tried:
python setup.py build --static-deps --libxml2-version=2.7.8 && pip install lxml
but it tells me:
RuntimeError: ERROR: Trying to build without Cython, but pre-generated 'src/lxml/lxml.etree.c' is not available (pass --without-cython to ignore this error).
And if I run the same command with the —without-cython option, I get:
error: command 'llvm-gcc-4.2' failed with exit status 1
(though I've installed XCode command line tools)
Thanks in advance for your help !
(fyi, I am using MacPorts and pip install…)
You mention Macports at the end and also pip. I think you are mixing up packaging and installation methods.
The first import error should not be seen using a macports python as it puts its libraries under /opt/
As you have started on macports I would use the easy way
port install py27-scrapy
This will install all the needed packages (including python and lxml) to get scrapyto work.
To run scrapy you would need to use the macports python in /opt/local/bin/python2.7. This can be set as the default python if /opt/local/bin is on your path and you run port select to choose this as the python found. The scrapy executable script is /opt/local/bin/scrapy-2.7 Version numbers are used because you can have multiple versions of python working at once.

ImageMagick on Mac OSX Snow Leopard. Is there any way to get it to compile and run?

It seems that I have more trouble getting standard Unix things to run on Snow Leopard than any other platform--including Windows cygwin
For the past couple of days, I've been trying to get ImageMagick to run on Snow Leopard.
The most obvious way, Mac Ports, fails:
tppllc-Mac-Pro:ImageMagick-sl swirsky$ sudo port install imagemagick
---> Computing dependencies for p5-locale-gettext
---> Configuring p5-locale-gettext
Error: Target org.macports.configure returned: configure failure: shell command " cd "/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_ports_perl_p5-locale-gettext/work/gettext-1.05" && /opt/local/bin/perl Makefile.PL INSTALLDIRS=vendor " returned error 2
Command output: checking for gettext... no
checking for gettext in -I/opt/local/include -arch i386 -L/opt/local/lib -lintl...gettext function not found. Please install libintl at Makefile.PL line 18.
no
Error: Unable to upgrade port: 1
Error: Unable to execute port: upgrade xorg-libXt failed
Before reporting a bug, first run the command again with the -d flag to get complete output.
tppllc-Mac-Pro:ImageMagick-sl swirsky$
Not wanting to spend another two days figuring out why my libintl doesn't have a "gettext" function, I tried a different route: the script mentioned here: http://github.com/masterkain/ImageMagick-sl
This script downloads and installs an ImageMagic independently of MacPorts issues
tppllc-Mac-Pro:ImageMagick-sl swirsky$ /usr/local/bin/convert
dyld: Library not loaded: /opt/local/lib/libiconv.2.dylib
Referenced from: /opt/local/lib/libfontconfig.1.dylib
Reason: Incompatible library version: libfontconfig.1.dylib requires version 8.0.0 or later, but libiconv.2.dylib provides version 7.0.0
Trace/BPT trap
It downloads everything and compiles fine, but fails when I try to run it, with the message above.
So now I'm two steps away from ImageMagick, trying to get a newer libiconv on my machine.
I downloaded the latest libiconv, compiled and built it. I put the resulting library in /opt/local/lib, and I still get the same error message:
tppllc-Mac-Pro:.libs swirsky$ sudo mv libiconv.2.dylib /opt/local/lib/libiconv.2.dylib
tppllc-Mac-Pro:.libs swirsky$ convert
dyld: Library not loaded: /opt/local/lib/libiconv.2.dylib
Referenced from: /opt/local/lib/libfontconfig.1.dylib
Reason: Incompatible library version: libfontconfig.1.dylib requires version 8.0.0 or later, but libiconv.2.dylib provides version 7.0.0
Trace/BPT trap
Now here's something interesting. The error message shows it's looking in /opt/local/lib/libiconv.2.dylib.
otools -L shows that this does implement 8.0.0:
tppllc-Mac-Pro:.libs swirsky$ otool -L /opt/local/lib/libiconv.2.dylib
/opt/local/lib/libiconv.2.dylib:
/usr/local/lib/libiconv.2.dylib (compatibility version 8.0.0, current version 8.0.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 125.0.0)
tppllc-Mac-Pro:.libs swirsky$
And, for good measure, I set the DYLD_LIBRARY_PATH to make sure this directory is the one for dynamic libraries.
So even though I do have a library that provides 8.0.0, it's being seen as 7.0.0! Any ideas why this would happen?
So here's my question: Is it possible to get ImageMagick to run on OSX Snow Leopard? Are there any binary distributions that have static libraries baked in so I don't have to worry about these issue/
This worked for me:
sudo brew install imagemagick
You may also try the ImageMagick install script located here:
http://github.com/masterkain/ImageMagick-sl
It helped me a lot. May be needed to change some library versions inside the script.
I've seen this exact error with this exact library in multiple situations. It was, in every case, an instance where either the individual or an script they were using was setting the DYLD_LIBRARY_PATH variable.
Make sure this variable is not being set as it overrides loading the explicitly linked libraries with those at that path.
If the DYLD_* must be set, use the more sane DYLD_FALLBACK_LIBRARY_PATH. Which will attempt to load the explicitly linked libraries first, then fallback to the user declared ones.
I did notice on your initial build that it was not finding the gettext library in macports. So make sure those are installed.
My google showed up a few hits, and the first or second one had a link to the binary.
I was finally able to get my "macports" installation consistent enough to get imagemagick installed and running. I had to manually delete my /opt/local/ directores where the files lived, and clean out some other dependencies.
It seems that the dynamic linker is pulling in the system libiconv.2.dylib (which has compatibility version 7.0.0). Without seeing your entire build process it's hard to know for sure why this is, but I'm suspicious of your libiconv build; note that in the following failure:
tppllc-Mac-Pro:.libs swirsky$ otool -L /opt/local/lib/libiconv.2.dylib
/opt/local/lib/libiconv.2.dylib:
/usr/local/lib/libiconv.2.dylib (compatibility version 8.0.0, current version 8.0.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 125.0.0)
your libiconv.2.dylib seems to think that its install path is /usr/local/lib, not /opt/local/lib. This probably why the dynamic linker isn't finding it; it's looking for it in /usr/local/lib, not finding it, and falling back on the system library in /usr/lib. Try setting the install path for your libiconv.2.dylib so that it's load commands tell the linker to look for it in /opt/local/lib, and that may resolve the issue.
I had the same problem, and solved it by uninstalling then reinstalling libiconv using Macports. Then everything works fine (I also have /opt/local/lib/ as the first entry in my DYLD_LIBRARY_PATH variable)
Strange. I'm pretty happy with my macports - and everything is compiled without errors. I can only advice - use macports.
ImageMagick #6.6.9-9_0+graphviz+hdri+jpeg2+mpeg+perl+q16+rsvg+wmf (active)

Resources