import sklearn error with anaconda python 3.52 - python

Fresh install of anaconda python3 onto secondary hard drive of mac running mavericks.
import sklearn
gives
Library not loaded: /usr/local/lib/libgcc_s.1.dylib
Referenced from: /Volumes/SecondHD/anaconda/lib/python3.5/site-packages/scipy/sparse/linalg/isolve/_iterative.so
Reason: image not found
gcc was installed with home-brew and exists.
which gcc
gives
/usr/bin/gcc
In /usr/local/Cellar/gcc/6.1.0/lib/gcc/6 I can find libgcc_s.1.dylib so I know it's there even tho it was not symlinked in /usr/local/lib.
Rather than adding more symlinks to /usr/local/lib from all the libraries in Cellar, I instead added the location of the libraries to the search path.
In my ~.profile I have
export LIBRARY_PATH="$LIBRARY_PATH:/usr/local/lib"
export LIBRARY_PATH="$LIBRARY_PATH:/usr/local/Cellar/gcc/6.1.0/lib/gcc/6"
But that does not work. However, the error goes away if I add this line to my .profile
export DYLD_FALLBACK_LIBRARY_PATH=/usr/local/Cellar/gcc/6.1.0/lib/gcc/6
My understanding from this post is that LIBRARY_PATH is a list of places a compiler (like gcc) will look for libraries when it is linking code. But in Mac OSX, DYLD_LIBRARY_PATH and DYLD_FALLBACK_LIBRARY_PATH contain a list of places any program will search for a shared library when it runs.
So if sklearn wants a gcc library, that would mean some compilation (and linking) will happen. Why is this line not sufficient
export LIBRARY_PATH="$LIBRARY_PATH:/usr/local/Cellar/gcc/6.1.0/lib/gcc/6"
and why is DYLD_FALLBACK_LIBRARY_PATH or DYLD_LIBRARY_PATH needed?

I had the same problem. What I did was creating symbolic links from my cellar folder of gcc to /usr/local/lib.
look for the right path of you gcc
ln -s /usr/local/Cellar/gcc/X.X.X/lib/gcc/6/* /usr/local/lib

Related

CMake - Installing issues to make package

For installing dlib, I followed this tutorial : http://www.pyimagesearch.com/2017/03/27/how-to-install-dlib/.
I am on Mac OS X 10.12.5 and using Python 3.5.
I run
$ brew install cmake
$ brew install boost
$ brew install boost-python --with-python3
It works without any error.
But when I try to install dlib with pip install dlib. I have an error :
The C compiler
"/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc"
is not able to compile a simple test program.
error: cmake configuration failed
ld: can't map file, errno=22 file '/usr/local/opt/qt/lib' for architecture x86_64
For the full error, please see on this link (doesn't want to paste the full error) :
https://gist.github.com/alexattia/3e98685310d90b65031db640d3ea716a
After retracing the error, when I tried to make dlib manually, I have this :
Linking C executable cmTC_05e45
/usr/local/Cellar/cmake/3.8.2/bin/cmake -E cmake_link_script
CMakeFiles/cmTC_05e45.dir/link.txt --verbose=1
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc
-Wl,-search_paths_first -Wl,-headerpad_max_install_names
/usr/local/opt/qt/lib CMakeFiles/cmTC_05e45.dir/testCCompiler.c.o -o
cmTC_05e45
For the full trace expand : https://gist.github.com/alexattia/1e54ffb87c9eb4c811033f5cadd90331
I reinstalled XCode (from Apple Store) and CMake (3.8.2 from the downloaded page), I even installed Qt Creator to have a clean version of Qt, but I still have the same error.
I tried to install it with conda but after the installation, I still don't have the module in python.
Thank you very much for any help.
You commented:
Indeed, in my .bash_profile, I have export LDFLAGS="/usr/local/opt/qt/lib",
export CPPFLAGS="/usr/local/opt/qt/include", export PATH="/usr/local/opt/qt/bin:$PATH".
But even while commenting it, I still have the same error
Neither of your assignments to LDFLAGS or CPPFLAGS makes sense, and the
first one is the cause the linker failure that concerns you.
The value of the environment variable LDFLAGS, if set, is interpreted by your build system
as linkage options. Likewise The value of the environment variable
CPPFLAGS, if set, is interpreted as preprocessor options.
/usr/local/opt/qt/lib is not a linkage option and /usr/local/opt/qt/include
is not a preprocessor option. These are simply directory names. Any argument that
you pass to the linker (or preprocessor, or compiler) that is not an option is
interpeted by the tool as an input file. Thus you have led the linker to believe
that /usr/local/opt/qt/lib is an input file to your linkage.
ld: can't map file, errno=22 file '/usr/local/opt/qt/lib' for architecture x86_64
is what the linker says when it discovers that /usr/local/opt/qt/lib is not
a file at all.
Presumably, you wish to instruct the linker that /usr/local/opt/qt/lib is
a directory in which it should search for libraries required by your linkage.
The linkage option that expresses that intent is:
-L/usr/local/opt/qt/lib
Here are the GCC options for linking
Similarly you intend to instruct that preprocessor that /usr/local/opt/qt/include
is a directory in which it should search for header files. The preprocessor
option to express that is:
-I/usr/local/opt/qt/include
Here are the GCC options for preprocessing
It is abnormal and inadvisable to specify compilation or linkage options
in your bash login profile, as you are doing. Specify such options in the
build system's input files (makefile, cmakelists file or similar), or as arguments to
the build system's configuration. But if you insist on specifying them in
your bash login profile, then you should specify:
LDFLAGS=-L/usr/local/opt/qt/lib
CPPFLAGS=-I/usr/local/opt/qt/include
And once you have made these environment settings in your bash_profile they will
only take effect in new login shells.
I had a similar issue but found out it was due to boost.
Try this.
brew uninstall boost-python
brew uninstall boost
brew install boost-python --with-python3 --without-python
pip3 install dlib

Building graph-tool on OSX with Python 3.4

I tried to install graph-tool on Mac OSX 10.10 using homebrew. The brew build process works fine, but when I try to import graph-tool I get the error described in this question.
Another problem with homebrew is that I always builds graph-tool for python2.7 and it installs the packages in the Python 2.7 sit-packages folder. But I want to use it with Python 3.4. These are the reasons why I tried to build graph-tool from source.
The ./configure command automatically uses Python 2.7, too. So I passed it the desired Python version with ./configure PYTHON=python3.4
It then detects the correct version as well as the related paths but crash with the following error:
configure: error:
Could not link test program to Python. Maybe the
main Python library has been installed in some non-standard library
path. If so, pass it to configure, via the LDFLAGS environment
variable.
Example: ./configure LDFLAGS="-L/usr/non-standard-path/python/lib"
======================================================================
ERROR!
You probably have to install the development version of the
Python package for your distribution. The exact name of this package varies
among them.
======================================================================
The error occurs with and without PYTHON variable set.
From the output of ./configure I can see that everything works fine except for the last line, which says:
checking consistency of all components of python development
environment... no
Whats does the above line mean and how do I properly install graph-tool on my maschine?
The error message is explaining exactly what needs to be done. Since python was installed in a non-standard path, you need to pass the flag LDFLAGS="-L/usr/non-standard-path/python/lib" pointing to the directory where the python libraries are located. This is most likely "/usr/local/lib", if you are using homebrew.
I was getting this error when I was trying to install graph-tool using outdated an autoconf / automake / pkg-config combination (installed using yum in CentOS 5.10). Installing those packages from source fixed the problem... although I'm not sure how this related to my python installation....
It worked for me by passing the variable PYTHON_EXTRA_LDFLAGS="-Wl,-stack_size,1000000 -F/usr/local/Cellar/python3/3.6.3/Frameworks -framework CoreFoundation".
In your case, it would be the path to the homebrew installation of python3.4.
The way I found out is that in the config.log, the error message shows the following:
configure:19023: checking python extra libraries
configure:19030: result: -ldl -framework CoreFoundation
configure:19037: checking python extra linking flags
configure:19044: result: -Wl,-stack_size,1000000 -framework CoreFoundation Python.framework/Versions/3.6/Python
configure:19051: checking consistency of all components of python development environment
configure:19079: gcc -o conftest -g -O2 -DNDEBUG -I/usr/local/Cellar/python3/3.6.3/Frameworks/Python.framework/Versions/3.6/include/python3.6m -F/usr/local/Cellar/python3/3.6.3/Frameworks/ -Wl,-stack_size,1000000 -framework CoreFoundation Python.framework/Versions/3.6/Python conftest.c -L/usr/local/opt/python3/Frameworks/Python.framework/Versions/3.6/lib -lpython3.6m -ldl -framework CoreFoundation -ldl -framework CoreFoundation >&5
clang: error: no such file or directory: 'Python.framework/Versions/3.6/Python'
The error seems to be path 'Python.framework/Versions/3.6/Python', that in a homebrew installation does not exist. I search for the same path in the config.log and I found this line:
PYTHON_EXTRA_LDFLAGS="-Wl,-stack_size,1000000 -framework CoreFoundation Python.framework/Versions/3.6/Python"
So, the solution for me was to pass this variable with the right path.

Running Python code for theano: /usr/bin/ld: cannot find -latlas

I am trying to run theano on ubuntu which requires libatlas.
I have already installed libatlas but I can find it in /usr/lib/atlas-base
I have also copied all of the files to a new folder called /atlas:
cp -a /usr/lib/atlas-base/* /usr/lib/atlas
But still, when I run the python code I see:
/usr/bin/ld: cannot find -latlas
/usr/bin/ld: cannot find -l477blas
/usr/bin/ld: cannot find -lcblas
I also tried adding to environment variables but didn't work:
set LIBPATH = [BUILD_LIB_DIR, /usr/lib/atlas]
Also I tried adding the path path to ld file:
/usr/lib/atlas
or
/usr/lib/atlas-base
None of them worked and I still see the error running the Python code.
To change how Theano link to BLAS, you need to use Theano flags[1]. They can be set with an environment variable THEANO_FLAGS or with a configuration file.
How did you told Theano to use atlas? If you just installed the atlas packages, it won't work. You need to install the libatlas-dev pacakge as per this Theano installation instruction for Ubuntu[2]
A last point, we don't recommand atlas, especially for Ubuntu. OpenBLAS is packaged for Unbuntu and is faster. See [2] for detail on how to installed them. You will need to remove atlas before installing openblas, otherwise, there will be conflict.
[1]http://www.deeplearning.net/software/theano/library/config.html#envvar-THEANO_FLAGS
[2]http://www.deeplearning.net/software/theano/install_ubuntu.html#install-ubuntu

Installing Theano on EPD (Windows x64)

I'm trying to install Theano on Enthought Python Distribution (EPD), but I am getting a weird error. Here is what my installation looks like:
I have installed EPD to C:\Python27.
After that, I have installed pip by using easy_install pip
I installed Theano by using pip install Theano
To test, I start ipython and type import theano. I get the following error:
Problem occurred during compilation with the command line below:
g++ -shared -g -IC:\Python27\lib\site-packages\numpy\core\include -IC:\Python27\include -o C:\Users\Ove\AppData\Local\Theano\compiledir_Windows-7-6.1.7601-SP1-Intel64_Family_6_Model_37_Stepping_5_GenuineIntel-2.7.2\lazylinker_ext\lazylinker_ext.pyd C:\Users\Ove\AppData\Local\Theano\compiledir_Windows-7-6.1.7601-SP1-Intel64_Family_6_Model_37_Stepping_5_GenuineIntel-2.7.2\lazylinker_ext\mod.cpp -LC:\Python27\libs -LC:\Python27 -lpython27
C:\Users\Ove\AppData\Local\Temp\ccIoNPlU.o: In function `initlazylinker_ext':C:/Users/Ove/AppData/Local/Theano/compiledir_Windows-7-6.1.7601-SP1-Intel64_Family_6_Model_37_Stepping_5_GenuineIntel-2.7.2/lazylinker_ext/mod.cpp:911: undefined reference to `__imp_Py_InitModule4'
collect2: ld returned 1 exit status
Exception: Compilation failed (return status=1): C:\Users\Ove\AppData\Local\Temp. C:/Users/Ove/AppData/Local/Theano/compiledir_Windows-7-6.1.7601-SP1-Intel64_Family_6_Model_37_Stepping_5_GenuineIntel-2.7.2/lazylinker_ext/mod.cpp:911: undefi. collect2: ld returned 1 exit status4'
Does anyone know how to get Theano to run with EPD?
The last release of Theano(0.5) has some problem on Windows. You need to install the bleeding edge version. You can update your version like this:
pip install --upgrade --no-deps git+git://github.com/Theano/Theano.git
This should solve the problem. If not, you probably have some conflict with a different installation of gcc. Do you have installed it with cygwin or mingw? EPD installs its own version of mingw.
I couldn't get Theano working with Enthought, but using the Anaconda python distribution I eventually got it working. Here's how:
uninstall Enthought and any other python version (start from scratch)
download and install Anaconda python distribution from this link: http://09c8d0b2229f813c1b93-c95ac804525aac4b6dba79b00b39d1d3.r79.cf1.rackcdn.com/Anaconda-1.5.0-Windows-x86_64.exe and click the option to use Anaconda as your default python version
to get the academic license, go to this page: https://store.continuum.io/cshop/academicanaconda and click the "free" button next to Anaconda Academic License (right side of page)
you should receive an email with an academic license .txt file. Follow the instructions in the email to place the file in the correct directory, and run several command-line commands to update anaconda and install numpy and scipy
open a windows command prompt and type
pip install theano
create a file .theanorc.txt containing the lines:
[global]
openmp=False
[blas]
ldflags=
place .theanorc.txt in your home folder (the folder for your user account)
make sure the following paths are added to your PATH environment variable:
C:\Anaconda\MinGW\bin;
C:\Anaconda\MinGW\x86_64-w64-mingw32\lib;
C:\Anaconda;
C:\Anaconda\Scripts;

Symlinking PIL from site packages on Snow Leopard to a virtualenv with no-site-packages not working

I have a virtualenv with --no-site-packages and am having all sorts of issues installing PIL in the virtualenv. The global PIL works fine. I'm trying to get this working by symlinking to PIL in the global site packages, which I know works. I tried:
ln -s /Library/Python/2.6/site-packages/PIL ~/my_virtualenv/lib/python2.6/site-packages/PIL
When I then try to import PIL from Python, that works fine. However I can't run import Image but this works for the system Python. I also tried just copying the directory wholesale, but no dice there either.
Any ideas on how to debug this? How does PIL export Image to the global "module space?"
Update: Thanks to #Sentinel's persistance, I was able to solve this problem. Examining the trace when installing PIL, I noticed a bunch of lines like so:
ld: warning: in /opt/local/lib/libjpeg.dylib, missing required architecture ppc in file
ld: warning: in /opt/local/lib/libz.dylib, missing required architecture ppc in file
Those are actual all the errors that are left, but originally there were others complaining about how I didn't have libjpeg for i386 or x64 architectures as well. So I backed up, removed the libjpeg I had installed to /usr/local/lib and just used macports to install the universal binaries (basically following the instructions at http://passingcuriosity.com/2009/installing-pil-on-mac-os-x-leopard/). Figuring this is what was causing the problem, libjpeg wasn't compiled for the architecture I needed. After doing that, I then installed the Imaging library and then everything worked -- no symlinking required. And now I can go to bed without thinking about this anymore, even if it took 4 hours to figure out. :)
Install the development libraries (jpeg, zip, etc.), then use the virtualenv (adding setuptools or pip to it as necessary) to install PIL into the virtualenv itself.

Categories