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
Related
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
Before I get to far into this, I should note that I have seen a very similar question, but the solution presented did not work for me. Perhaps one reason why is because that was Linux build and my current difficulty is on a Windows 7 machine. I use Cygwin to get access to the gcc (5.2.0) compiler suite.
In any event, I have been attempting to try out Stan via PyStan. I am working with an Anaconda (2.4.1 64-bit) distribution which I just updated today (Python 2.7.11). I initially tried to install PyStan via pip, but the install keeps failing due to what looks like the following error:
Cannot build msvcr library: "msvcr90d.dll" not found
Consequently, I used conda instead, which seemed to install just fine. (I should note that the conda install pushed my numpy back to an earlier version, which created conflicts with the pandas upon import. I just updated anaconda to deal with these broken dependencies.) I was also able to import PyStan without any problems. However, when I actually tried to fit a model (inside of a Jupyter Notebook), the process failed with the exception in the title.
The first thing I did was confirm that gcc was where in the referenced location (not shown in the title). Indeed it was, and it seemed to working just fine. I then tried to run the model as a script from the command line (still using Python), and it failed with the same error. When I recreated the model via the REPL, it pointed to a different location that had a .bat file referencing the (verified) compiler, and that failed as well.
I am pretty sure this is because I have Visual Studio 2012, instead of Visual Studio 2008. While it is possible for me to run parallel installations, if this code is going to be useful for others in the future, these are not reasonable hoops to jump through to make it happen. I was hoping that someone else might have a better explanation. Any info would be greatly appreciated.
Beneficial from the post at https://github.com/stan-dev/pystan/issues/306
I have met various error message, but finally, I install PyStan successfully.
My machine is also on Windows 7, x64 with Anaconda3 installed.Here are the procedures to install PyStan from the sourced codes.
Install Visual Studio 2017 & Visual Studio C++ Build Tool 2015 at http://landinghub.visualstudio.com/visual-cpp-build-tools
Update Conda
conda update conda
conda update --all
check the dependencies
pip install setuptool
conda install numpy cython matplotlib scipy pandas
Install gcc compiler components
conda install libpython
conda install -c msys2 m2w64-toolchain=5.3.0
created distutils.cfg file inside Anaconda3\Lib\distutils folder with the following:
[build]
compiler = mingw32
Download Git at https://git-scm.com/downloads
git clone --recursive https://github.com/stan-dev/pystan.git
Compile from the source code
python setup.py build --compiler=mingw32
python setup.py install
P.S. The solution for the issue: Cannot build msvcr library: "vcruntime140d.dll" not found.
Copy vcruntime140d.dll from C:\Windows\System32 to any folder, which is reachable in the path in the advanced system settings/environment variables/ system variables.
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;
I am setting up Python and Django on os X 10.7 from a virgin install and Xcode 4.3.
I tried using the default install of Python:
/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/
I normally use a Python based package manager called easy_install.
Easy_install seems to not be able to find the compiler.
EDIT: When I tried to install MySQL-python I got this error:
$ sudo easy_install MySQL-python
Password:
Searching for MySQL-python
Reading http://pypi.python.org/simple/MySQL-python/
Reading http://sourceforge.net/projects/mysql-python/
Reading http://sourceforge.net/projects/mysql-python
Best match: MySQL-python 1.2.3
Downloading http://download.sourceforge.net/sourceforge/mysql-python/MySQL-python-1.2.3.tar.gz
Processing MySQL-python-1.2.3.tar.gz
Running MySQL-python-1.2.3/setup.py -q bdist_egg --dist-dir /tmp/easy_install-P9H9WX/MySQL-python-1.2.3/egg-dist-tmp-rRTfZL
warning: no files found matching 'MANIFEST'
warning: no files found matching 'ChangeLog'
warning: no files found matching 'GPL'
unable to execute llvm-gcc-4.2: No such file or directory
error: Setup script exited with error: command 'llvm-gcc-4.2' failed with exit status 1
error: Setup script exited with error: command 'llvm-gcc-4.2' failed with exit status 1
Apparently, the system attempts to use the same compiler used to compile the installed Python framework.
For some reason Apple didn't include llvm-gcc-4.2.
Xcode 4.1 used GCC, but with Xcode 4.3 that seems to have changed.
From what I can gather, Apple wants to use Clang as the compiler vs GCC.
So I added to .bash_profile:
cc=clang
I decided I would just recompile Python with clang but first, I needed to install readline.
Fail:
Wed Feb 22 16:04:59 ~/Downloads/readline-6.2
$ ./configure
checking build system type... i386-apple-darwin11.3.0
checking host system type... i386-apple-darwin11.3.0
Beginning configuration for readline-6.2 for i386-apple-darwin11.3.0
checking whether make sets $(MAKE)... no
checking for gcc... no
checking for cc... no
checking for cl.exe... no
configure: error: in `/Users/Bryan/Downloads/readline-6.2':
configure: error: no acceptable C compiler found in $PATH
See `config.log' for more details.
What the easiest way to install Django on Lion 10.7?
Did you install the command-line tools with Xcode 4.3? They are not installed by default. You can install them by going to the Downloads pane in Xcode 4.3's preferences.
Making it way too hard:
First, make sure you install Xcode (available for free in the Mac App Store). It includes all the build tools that might be necessary to compile certain Python packages.
To get easy_install just download setuptools and follow the instructions for installing on Mac OS X at that link.
Once that's done, you can easy_install virtualenv to get a nice segregated environment to work in.
For the MySQL issue you have to edit the site.cfgfile:
mysql_config = /usr/local/mysql/bin/mysql_config
And then:
$ python setup.py build
$ sudo python setup.py install
Try updating XCode and reinstall all global site-packages. You may also want to try pip instead of easy_install.
You can also try to compile with
export ARCHFLAGS='-arch i386 -arch x86_64'
This solved many of my problems in the past when upgrading OSX versions.
I have the newest XCode (4D199) installed and in terminal when I type
new-host-2: me$ gcc -version
i686-apple-darwin11-llvm-gcc-4.2: no input files
Is that the default xcode/mac gcc compiler version? Because when I try to do a
sudo easy_install cython
I get:
Running Cython-0.15.1/setup.py -q bdist_egg --dist-dir /tmp/easy_install-qS3Kqb/Cython-0.15.1/egg-dist-tmp-Zh0Vnv
cc1: error: unrecognized command line option "-arch"
cc1: error: unrecognized command line option "-arch"
I've read that -arch is a Apple GCC compiler only function. I think when I installed a port from macports I remember it installing something called "llvm" and now I suspect that that is being used instead of the one that comes with XCODE.
Any way to switch it back?
Oh, and when I type "sudo port select gcc" I get (this might be relevent to knowing which gcc version I have):
Available versions for gcc:
apple-gcc42
gcc42
llvm-gcc42
mp-gcc44
mp-llvm-gcc42
none
Does sound like you're getting a non-apple version. If you don't need any non-standard compilers, I'd remove any that macports has installed. The apple infrastructure is different enough that using compilers from macports causes grief fairly easily.
This is not extremely related to your problem but you will find a solution here: Can't install Ruby under Lion with RVM – GCC issues
This answer was edited multiple times and now contains three alternative solutions. Skip to the end and try the simple “edit 3” solution first, it seems to work for most people.
You need a non-LLVM version of GCC, which is no longer included with XCode 4.2. Install it yourself (or downgrade to XCode 4.1 temporarily), then do CC=/usr/local/bin/gcc-4.2 rvm install 1.9.3 (substituting the path to your non-LLVM gcc).
Edit: https://github.com/kennethreitz/osx-gcc-installer/downloads may help for installing GCC.
Edit 2 (apparently the easiest solution): Alternatively you can try to add --with-gcc=clang to the arguments to configure for Ruby to use clang.
Edit 3: rvm install 1.9.3 --with-gcc=clang does that for you.