GotoBLAS error when installing matplotlib with pip in a virtualenv on debian wheezy - matplotlib

I'm trying to install matplotlib with pip in a virtualenv on debian wheezy.
And i get the following message:
Running setup.py egg_info for package matplotlib
GotoBLAS : Architecture Initialization failed. No initialization function found.
============================================================================
Edit setup.cfg to change the build options
BUILDING MATPLOTLIB
matplotlib: yes [1.3.1]
python: yes [2.7.3 (default, Jan 2 2013, 13:56:14) [GCC
4.7.2]]
platform: yes [linux2]
REQUIRED DEPENDENCIES AND EXTENSIONS
Complete output from command python setup.py egg_info:
GotoBLAS : Architecture Initialization failed. No initialization function found.
============================================================================
Edit setup.cfg to change the build options
BUILDING MATPLOTLIB
matplotlib: yes [1.3.1]
python: yes [2.7.3 (default, Jan 2 2013, 13:56:14) [GCC
4.7.2]]
platform: yes [linux2]
REQUIRED DEPENDENCIES AND EXTENSIONS
----------------------------------------
I previously had libopenblas-dev installed. In fact, I managed to install matplotlib in Ubuntu Gnome 13.10 using the same procedure.
Any ideas?
Update 1:
I finally installed matplotlib from the distribution packages. Then based on this question I created an environment using the flag --system-site-packages.
To test the installation I tried to import matplotlib in python:
>>> import matplotlib
GotoBLAS : Architecture Initialization failed. No initialization function found.
But I get the same error :( .
Update 2:
I found this post. It is the same error and it was on KVM, just like me. Maybe this error is related with KVM?
I just installed matplotlib without problems in debian wheezy running over VirtualBox. But I really need to install it on the KVM machine.
Update 3:
The same error occurs when trying to import numpy in the same system:
>>> import numpy
GotoBLAS : Architecture Initialization failed. No initialization function found.

this worked for me:
sudo apt-get purge libopenblas-dev

I finally found a solution! I followed the procedure in Daniel Nouri's Blog.
Here's a summary:
Install libatlas3-base:
sudo apt-get install libatlas3-base
Use liblapack3.so.3 from /usr/lib/atlas-base/atlas/liblapack.so.3 as your default:
sudo update-alternatives --config libblas.so.3

Related

Install numpy for Python 3.7 in Ubuntu 18.04

I'm having trouble installing numpy on Ubuntu 18.04 for Python 3.7... here's what I tried:
(venv) root#servername:/path$ pip3.7 install numpy --no-cache-dir
Collecting numpy
Downloading numpy-1.19.5-cp37-cp37m-manylinux2010_x86_64.whl (14.8 MB)
|████████████████████████████████| 14.8 MB 8.6 MB/s
Installing collected packages: numpy
Successfully installed numpy-1.19.5
I get this ImportError:
Original error was: No module named 'numpy.core._multiarray_umath'
... but I've been focusing on this as the probable cause, from that same error message:
* The Python version is: Python3.6 from "/path/venv/bin/python"
... that says Python 3.6, but I'm trying to use Python3.7, and that python is on 3.7:
(venv) root#servername:/path$ /path/venv/bin/python --version
Python 3.7.9
I saw in another answer that upgrading can help, so I tried this - it looks like I'm already on the latest:
(venv) root#servername:/path$ pip install numpy --upgrade
Requirement already satisfied: numpy in ./venv/lib/python3.7/site-packages (1.19.5)
How can I get this working?
This was failing for me while using mod-wsgi with Apache - I had to load mod-wsgi for Python 3.7 instead of the system default of 3.6. The instructions are at https://github.com/GrahamDumpleton/mod_wsgi/issues/467, but in case that goes away:
Using your venv, run "mod_wsgi-express module-config"
Put the resulting load command into your apache's mods-enabled/wsgi.load

Error installing matplotlib in a virtual environment python 2.7

I have been trying to install matplotlib in a virtual environment using pip.
after working on the virtual environment I tried:
$pip install matplotlib
but I get the error:
unable to execute 'c++' : No such file or directory
error : command 'c++' failed with exit status 1
------------------------------------------
Cleaning up
I am on ubuntu 14.04 and matplotlib works well for me when not using virtualenv, but I would like to have it in a virtualenv for separate projects that I have.
any suggestions?
Solved this problem by just upgrading pip, it seems there was an issue of version 1.5.4 which was installed when creating virtualenv.
$ pip install --upgrade pip
then installed matplotlib using pip
$pip install matplotlib

RuntimeError: module compiled against API version a but this version of numpy is 9 in ubuntu

I just installed theano, but
import numpy
print numpy.version
here is the output
Theano version 0.7.0.dev-30cc6380863b08a3a90ecbe083ddfb629a56161d
theano is installed in /home/sizhexi/theano/Theano/theano
NumPy version 1.8.2
NumPy is installed in /usr/lib/python2.7/dist-packages/numpy
Python version 2.7.6 (default, Jun 22 2015, 17:58:13) [GCC 4.8.2]
nose version 1.3.1
RuntimeError: module compiled against API version a but this version of numpy is 9
terminate called after throwing an instance of 'std::runtime_error'
what(): numpy failed to initialize
Aborted (core dumped)
how to solve it?
Package management in python is sometimes tricky. To avoid these issues, I recommend using Anaconda which is a good python package and environment manager (download here, and 30 minutes guide).
Follow the official instructions to install Anaconda and chose the default values that will add Anaconda to your $PATH and make Anaconda your default python interpreter. Then open your terminal and use the following commands :
conda install pip six nose numpy scipy
pip install theano
Then try running your script using anaconda.

Matplotlib install failure on Mac OSX 10.8 Mountain Lion

I tried to install matplotlib on my MacBook Air, but it always gives me this error message:
Processing matplotlib-1.1.1_notests.tar.gz
Running matplotlib-1.1.1/setup.py -q bdist_egg --dist-dir /tmp/easy_install-3jFpXK/matplotlib-1.1.1/egg-dist-tmp-jC7QY3
basedirlist is: []
============================================================================
BUILDING MATPLOTLIB
matplotlib: 1.1.1
python: 2.7.2 (default, Jun 20 2012, 16:23:33) [GCC 4.2.1
Compatible Apple Clang 4.0
(tags/Apple/clang-418.0.60)]
platform: darwin
REQUIRED DEPENDENCIES
numpy: 1.6.1
freetype2: found, but unknown version (no pkg-config)
* WARNING: Could not find 'freetype2' headers in any
* of '.', './freetype2'.
OPTIONAL BACKEND DEPENDENCIES
libpng: found, but unknown version (no pkg-config)
* Could not find 'libpng' headers in any of '.'
Tkinter: Tkinter: version not identified, Tk: 8.5, Tcl: 8.5
Gtk+: no
* Building for Gtk+ requires pygtk; you must be able
* to "import gtk" in your build/install environment
Mac OS X native: yes
Qt: no
Qt4: no
PySide: no
Cairo: no
OPTIONAL DATE/TIMEZONE DEPENDENCIES
datetime: present, version unknown
dateutil: 1.5
pytz: matplotlib will provide
adding pytz
OPTIONAL USETEX DEPENDENCIES
dvipng: 1.14
ghostscript: 9.05
latex: 3.1415926
[Edit setup.cfg to suppress the above messages]
pymods ['pylab']
packages ['matplotlib', 'matplotlib.backends', 'matplotlib.backends.qt4_editor', 'matplotlib.projections', 'matplotlib.testing', 'matplotlib.testing.jpl_units', 'matplotlib.tests', 'mpl_toolkits', 'mpl_toolkits.mplot3d', 'mpl_toolkits.axes_grid', 'mpl_toolkits.axes_grid1', 'mpl_toolkits.axisartist', 'matplotlib.sphinxext', 'matplotlib.tri', 'matplotlib.delaunay', 'pytz']
warning: no files found matching 'KNOWN_BUGS'
warning: no files found matching 'INTERACTIVE'
warning: no files found matching 'MANIFEST'
warning: no files found matching '__init__.py'
warning: no files found matching 'examples/data/*'
warning: no files found matching 'lib/mpl_toolkits'
warning: no files found matching 'LICENSE*' under directory 'license'
clang: warning: argument unused during compilation: '-mno-fused-madd'
In file included from src/ft2font.cpp:3:
src/ft2font.h:16:10: fatal error: 'ft2build.h' file not found
**#include <ft2build.h>
^
1 error generated.
error: Setup script exited with error: command 'clang' failed with exit status 1**
I tried to install freetype and libpng using homebrew but it doesn't work. How can I get ft2build.h?
The following worked for matplotlib installation after installing python according to instructions from thegreenroom. Those instructions didn't work for me after I installed Python. I followed the instructions from Scipy.org to install numpy and scipy. Then I did (adapted from above answer):
brew install freetype
brew install libpng
However I got the same error message whether I installed with pip install matplotlib or trying to install from source, doing
python setup.py build
python setup.py install
in the matplotlib directory I cloned via git clone https://github.com/matplotlib/matplotlib.git.
The error persisted until I ran
brew link freetype
Then from the cloned matplotlib directory I ran
python setup.py build
python setup.py install
And the installation succeeded.
This may help folks looking for a non-homebrew solution.
My goal: use pip install to build matplotlib for a non-system python 2.7.3 build.
Using latest X-Code and X-Code command line tools as of Feb 2013, no matter what gymnastics I tried, I always received C++ ostream related template errors when compiling ft2build with gcc.
I was able to get a pip install to work with the following env vars:
export CC=clang
export CXX=clang++
export LDFLAGS="-L/usr/X11/lib"
export CFLAGS="-I/usr/X11/include -I/usr/X11/include/freetype2"
I simply forced clang and added my xquartz paths. No extra pkg-config or libpng builds, no sudo-ed symlinks.
I think the other answers are on the right track, but I encountered this same problem and can attest that:
brew install pkg-config
brew install freetype
pip install matplotlib
would yield the same result. Typically on an Ubuntu box my next response would have been
sudo apt-get install libfreetype-dev
or some variation of that to install the header. However, I could find no such homebrew package. Furthermore, I was able to locate the header file in question in a pretty normal location on my system:
zoidberg:~ matt$ locate ft2build.h
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.7.sdk/usr/X11/include/ft2build.h
/usr/X11/include/ft2build.h
So I suspect there's either a problem with my system paths or with the homebrew packaged matplotlib. Since I'm lazy, I just tried installing the matplotlib package head from github:
pip install git+git://github.com/matplotlib/matplotlib.git#egg=matplotlib-dev
and it worked for me.
Here's the brew + pip recipe I used from a cold start. If you already have python and gfortran and such, jump in at the point where you need. The crucial steps appear to be brew install freetype and brew install libpng prior to doing pip install matplotlib
$ ruby -e "$(curl -fsSkL raw.github.com/mxcl/homebrew/go)"
$ brew doctor
$ brew install python
$ export PATH=/usr/local/bin:/usr/local/share/python:$PATH
$ easy_install pip
$ brew install gfortran
$ pip install numpy
$ pip install scipy
$ brew install pkg-config
$ brew install freetype
$ brew install libpng
$ pip install matplotlib
$ python
>>> import numpy
>>> import scipy
>>> import matplotlib
Note the 'no pkg-config' notices. You should have pkg-config on your search path, and it presumably needs to be the homebrew version so that it knows where the homebrew versions of the libraries are.
You need freetype:
brew install freetype
See the following:
http://comments.gmane.org/gmane.comp.python.matplotlib.general/31394
I also use mac air with OS X ver 10.8.2.
Using following commands can get rid of this failure:
brew install freetype
brew install libpng
pip install matplotlib
That's all. There may be some warning in the installing process, but that does not affect.
Use following python code to test:
import matplotlib.pyplot as plt
plt.plot([1,2,3,4])
plt.ylabel('some numbers')
plt.show()
which is referred from the url: http://matplotlib.org/users/pyplot_tutorial.html.
I have found installing these pacakges via homebrew to be the most reliable method
# if you haven't installed python via brew already:
brew install python
# sets up python as default python instead of system python
brew link python
# Add more brew formulae so we can install our py libs with brew
brew tap samueljohn/python
brew tap homebrew/science
# install numpy,scipy,matplotlib and dependencies ( gfortran, etc.. )
brew install numpy
brew install scipy
brew insatll matplotlib
I am using MacOs 10.8 too, and I encountered the same problem regarding not finding ft2build.h header when I tried to install matplotlib, what I l did to resolve the reported issue is :
1) replacing "ft2build.h" in the following call within the file "setupext.py" :
return self._check_for_pkg_config('freetype2',
'ft2build.h',
min_version='2.4',
version=version)
by the complete path to the ft2build.h header, in my case :
return self._check_for_pkg_config('freetype2',
'/usr/local/Cellar/freetype/2.5.2/include/freetype2/ft2build.h',
min_version='2.4',
version=version)
I think, but have not tested, that the problem is solved in an upstream commit of matplotlib. Here is my reasons why:
Discussion:
https://github.com/vbraun/sage/commit/5d17ca989eb58559af8f43b43e368c378c1bf6bb
Fix:
https://github.com/vbraun/sage/blob/5d17ca989eb58559af8f43b43e368c378c1bf6bb/build/pkgs/matplotlib/patches/pkg-config.patch
I fixed the problem with Cyris's answer thought.
I also had a similar issue, and fixed it in a reasonably straightforward way using homebrew.
You don't have to link the freetype libraries for this reason. The main problem is, after you install freetype using homebrew, you are told to add
-I/usr/local/opt/freetype/include
to your CPPFLAGS. However, this alone is not sufficient, and you also have to add the the freetype2 subfolder as well.
So in order to install matplotlib, do this:
brew install freetype
brew install libpng
LDFLAGS="-L/usr/local/opt/freetype/lib -L/usr/local/opt/libpng/lib" CPPFLAGS="-I/usr/local/opt/freetype/include -I/usr/local/opt/libpng/include -I/usr/local/opt/freetype/include/freetype2" pip install matplotlib

Theano fails due to NumPy Fortran mixup under Ubuntu

I installed Theano on my machine, but the nosetests break with a Numpy/Fortran related error message. For me it looks like Numpy was compiled with a different Fortran version than Theano. I already reinstalled Theano (sudo pip uninstall theano + sudo pip install --upgrade --no-deps theano) and Numpy / Scipy (apt-get install --reinstall python-numpy python-scipy), but this did not help.
What steps would you recommend?
Complete error message:
ImportError: ('/home/Nick/.theano/compiledir_Linux-2.6.35-31-generic-x86_64-with-Ubuntu-10.10-maverick--2.6.6/tmpIhWJaI/0c99c52c82f7ddc775109a06ca04b360.so: undefined symbol: _gfortran_st_write_done'
My research:
The Installing SciPy / BuildingGeneral page about the undefined symbol: _gfortran_st_write_done' error:
If you see an error message
ImportError: /usr/lib/atlas/libblas.so.3gf: undefined symbol: _gfortran_st_write_done
when building SciPy, it means that NumPy picked up the wrong Fortran compiler during build (e.g. ifort).
Recompile NumPy using:
python setup.py build --fcompiler=gnu95
or whichever is appropriate (see python setup.py build --help-fcompiler).
But:
Nick#some-serv2:/usr/local/lib/python2.6/dist-packages/numpy$ python setup.py build --help-fcompiler
This is the wrong setup.py file to run
Used software versions:
scipy 0.10.1 (scipy.test() works)
NumPy 1.6.2 (numpy.test() works)
theano 0.5.0 (several tests fails with undefined symbol: _gfortran_st_write_done')
python 2.6.6
Ubuntu 10.10
[UPDATE]
So I removed numpy and scipy from my system with apt-get remove and using find -name XXX -delete of what was left.
Than I installed numpy and scipy from the github sources with sudo python setpy.py install.
Afterwards I entered again sudo pip uninstall theano and sudo pip install --upgrade --no-deps theano.
Error persists :/
I also tried the apt-get source ... + apt-get build-dep ... approach, but for my old Ubuntu (10.10) it installs too old version of numpy and scipy for theano: ValueError: numpy >= 1.4 is required (detected 1.3.0 from /usr/local/lib/python2.6/dist-packages/numpy/__init__.pyc)
I had the same problem, and after reviewing the source code, user212658's answer seemed like it would work (I have not tried it). I then looked for a way to deploy user212658's hack without modifying the source code.
Put these lines in your theanorc file:
[blas]
ldflags = -lblas -lgfortran
This worked for me.
Have you tried to recompile NumPy from the sources?
I'm not familiar with the Ubuntu package system, so I can't check what's in your dist-packages/numpy. With a clean archive of the NumPy sources, you should have a setup.py at the same level as the directories numpy, tools and benchmarks (among others). I'm pretty sure that's the one you want to use for a python setup.py build.
[EDIT]
Now that you have recompiled numpy with the proper --fcompiler option, perhaps could you try to do the same with Theano, that is, compiling directly from sources without relying on a apt-get or even pip. You should have a better control on the build process that way, which will make debugging/trying to find a solution easier.
I had the same problem. The solution I found is to add a hack in theano/gof/cmodule.py to link against gfortran whenever 'blas' is in the libs. That fixed it.
class GCC_compiler(object):
...
#staticmethod
def compile_str(module_name, src_code, location=None,
include_dirs=None, lib_dirs=None, libs=None,
preargs=None):
...
cmd.extend(['-l%s' % l for l in libs])
if 'blas' in libs:
cmd.append('-lgfortran')
A better fix is to remove atlas and install openblas. openblas is faster then atlas. Also, openblas don't request gfortran and is the one numpy was linked with. So it will work out of the box.