Matplotlib install issues. Pip Centos - Freetype "Missing" when it is installed - django

I am using a virtualenv for a django setup. I am trying to build a view that pulls data from logs and then graphs the data. Eventually I would like to have this real-time and live. If you have any recommendations on other solutions that would suit my project best, please do not hesitate to include them in the comment fields below.
I have attempted to install matplotlib from pip using pip install matplotlib.
I receive the following message:
* The following required packages can not be built:
* freetype
I then validated that it was installed
yum install freetype
Package freetype-2.3.11-14.el6_3.1.x86_64 already installed and latest version
I then found that there is a python-matplotlib which is an older version .99. However, I want to keep this inside of the virtual environment and not system wide.
find / -name *freetype*
/var/lib/yum/yumdb/f/d2807dcfe3762c0b9f8ef1d9bf0f05788e73282a-freetype-2.3.11-14.el6_3.1- x86_64
/usr/lib64/libfreetype.so.6.3.22
/usr/lib64/libfreetype.so.6
/usr/share/doc/freetype-2.3.11
I searched all over stackoverflow and only saw solutions for ubuntu which did not transfer over to centos.
Thank you for your time,
John

pip is going to compile matlibplot on your local machine, so you'll need freetype development headers installed as well.
CentOS 6+, Fedora, etc.:
$ sudo yum -y install freetype freetype-devel libpng-devel
On older operating systems (e.g. CentOS 5), you may run into a more specific freetype versioning issue with newer releases of matlibplot. If you're version agnostic, sticking with a legacy 1.3.x release will negate these dependency issues:
$ pip install matplotlib==1.3.1
Please note, you may need to downgrade your numpy to 1.8 in order to make matplotlib 1.3 work.
$ pip install numpy==1.8
Good luck!

I have just had a similar (albeit not exactly the same) situation. I'll write it up here as this page comes up among the first search results.
CentOS 5
pip install matplotlib complains about freetype
Both freetype and freetype-devel are installed.
~/.pip/pip.log provides the explanation of the problem. There is the line:
freetype: no [Requires freetype2 2.3 or later. Found 2.2.1.]
Obviously, the solution is either to upgrade freetype or downgrade matplotlib.
The second is easier (assuming I am OK with the older version).
pip install matplotlib==1.3.1 works fine.

On the matplotlib installation, this is what I did. Not sure if this is going to help you. Just followed the steps here:
http://pkgs.org/centos-6/centos-x86_64/python-matplotlib-0.99.1.2-1.el6.x86_64.rpm.html
I did not use pip, btw and have CentOS 6.4.

I had this happen to me in two different situations, see if yours is one of them:
freetype was installed, but not in the $PATH yet. Just exiting the shell and starting a new one fixed this.
I was building matplotlib from source, and trying to build from the master branch. After I switched to v1.3.x it correctly detected freetype.

Related

Statsmodels Installation Error

Whenever I tried to install "Statsmodels" using pip or easy_install the following error is showing.
enter image description here
I have tried to install scipy individually, same thing happens. What to do?
Installing statsmodels is quite easy, when numpy and scipy is available.
Installing scipy (using pip or easy_install = from sources by default) on the other hand is a nightmare on Windows, as it needs a C-Compiler, Fortran-Compiler and for example BLAS which is the error shown in your case.
The official docs of scipy do not recommend this manual install on Windows.
A few years ago there were official prebuilt binaries, but that's not the case anymore.
A few sources of prebuilt binares are given in the docs above and i highly recommend anaconda.

Python (Win 10): Installing matplotlib requires packages "freetype" and "png"?

I've been trying to install Python's matplotlib library for use with PyPlot, for use with Julia. I managed to get everything in place except for this one final library, and I feel as though I've hit a deadend trying to get it working.
When trying to install matplotlib (I've attempted using pip, regular python install, and easy_install), I get the following message at the very end of the install output, after which it is NOT installed:
* The following required packages can not be built:
* freetype, png
Confused about this, I looked around online and installed both of these (at least, what I think these were). One was the freetype project, and the other was LibPng, which was the closest thing I could find to a "png package" for windows or python in general.
This didn't initially work (for either of them), and I read somewhere that I needed a freetype.dll in my system32 folder. It was a long shot, but I went to where I installed freetype and pulled out the dll and renamed it, placing it in system32. This of course did not work (again, long shot).
Anyway, that's where I'm at. No idea where to go from here, and I'm unsure if I even grabbed the correct "packages" I should be using. Thoughts?
Use a more powerful installer
I would recommend to use Anaconda or Miniconda. In my experience with many Windows users, this is the simplest way to install packages such as matplotlib.
Anaconda
Anaconda comes with many packages for scientists. Matplotlib works out of the box. Just install as user not root.
Minoconda
If you don't want all packages of Ananconda use Miniconda
Conda
Both ways of installation (Anaconda or Miniconda) provide conda. It is an improved pip/virtualenv.
You can install matplotilb with this command:
conda install matplotlib
Enviroments:
You can create a new environment and install the packages you like:
conda create -n my_project35 python=3.5
activate my_project35
conda install matplotlib
or
conda create -n my_project27 python=2.7
activate my_project27
conda install matplotlib
Combine with pip
You can still use pip. conda "understands" what it is doing.
One snake is enough!
[This is for folks using the Linux Bash Shell on Windows 10.]
If you don't want to go the Anaconda route, you can install freetype (and png) by executing the following in the Windows 10 Bash shell:
sudo apt-get install freetype6-dev
The above command will also automatically install libpng. However, due to an error, the system will not 'realize' it has installed freetype, so you'll need to manually install pkg-config:
sudo apt-get install pkg-config
Thereafter you should be able to install matplotlib via pip without further incident.
sudo pip install matplotlib
I tired downloading matplotlib 2.2.2 with python 3.9.5, getting freetype & png errors for hours.
After downloading python 3.7.9 and removing python 3.9.5 from environment variables, installing matplotlib 2.2.2 worked with no problems!
Change your Python Version
Go to https://www.python.org/downloads/windows/, control-f search 3.7.9 and use the webinstaller. Follow all the recommended instructions
In pyvenv.cfg in your project directory switch version number to 3.7.9 and home to C:.....\Python37.
pip3 install alpaca-backtrader-api

How do I open a .whl binary installation file in CMD? Win Py 2.7 Err "No distributions at all found for lxml-3.4.4-cp27-none-win32.whl"

I've been at this for nearly 2 hours and I just can't seem to get my head around it. I am a novice Pythoner, it would appear. I am trying to intsall lxml, (needed to install scrapy). I have tried multiple methods (see my other current quesitons).
Currently I am trying the following.
I downloaded the lxml win 32 file for python 2.7 from this website:
https://pypi.python.org/pypi/lxml/3.4.4#downloads
The LXML Binaries are also available here: "http://www.lfd.uci.edu/~gohlke/pythonlibs/#lxml"
I download the .whl file.
I then open up CMD, and CD to my download folder. Once in that folder I run the following command (as per the answer to this question here: How do I install a Python package with a .whl file?)
pip install lxml-3.4.4-cp27-none-win32.whl
This is the output:
C:\Users\Charles\Downloads\python>pip install lxml-3.4.4-cp27-none-win32.whl
Downloading/unpacking lxml-3.4.4-cp27-none-win32.whl
Could not find any downloads that satisfy the requirement lxml-3.4.4-cp27- none
-win32.whl
No distributions at all found for lxml-3.4.4-cp27-none-win32.whl
Storing complete log in C:\Users\Charles\AppData\Roaming\pip\pip.log
Can anyone help me figure out what this means/what is going on? How can I execute this file to install the lxml as needed?
Many thanks!!
Edit: I am using Windows 64 bit, but from this question here: "easy_install lxml on Python 2.7 on Windows" the file I have selected appears to be the correct one.
I am using Windows 64 bit and use Scrapy. It took a while for me to figure out the best way to set up my virtualenv because lxml would not simply pip install.
So I did somethine very similar to what you did but it looks at first glance we may just be using different sites. So try downloading this .whl from HERE. Specifically, for your specifications I believe, grab the one that reads
lxml-3.4.4-cp27-none-win_amd64.whl
and then just cd to the downloads folder and pip install lxml-3.4.4-cp27-none-win_amd64.whl
The first thing you should do is upgrade pip; the latest version is 8.0. Next, you need to install wheel support (this step may be redundant in later versions) and then finally install your wheel:
pip install --upgrade pip
pip install wheel
lxml needs a lot of source-level dependencies, which are difficult to install in Windows. This is why the project provides binary installers for Windows. You can download these from the pypi page for lxml. Make sure you choose the right version for your environment:
lxml-3.4.4.win32-py2.7.exe - for Python 2.7 running on Windows 32-bit
lxml-3.4.4.win32-py3.2.exe - for Python 3.2 running on Windows 32-bit
lxml-3.4.4.win-amd64-py2.7.exe - for Python 2.7, running on Windows 64-bit

lapack/blas-related error when trying to add scipy to miniconda-installed copy of python 2.7.10 on RedHat 6

I have two versions of python on my RedHat 6 machine: 2.7.8 that came with the system originally and 2.7.10 that I've installed using miniconda for a project. I have to use the newer version to run some demo code for another project. The demo script produced this error:
ImportError: No module named scipy.sparse
Running pip install scipy failed with a bunch of warnings and then this:
numpy.distutils.system_info.NotFoundError: no lapack/blas resources found
numpy is already installed. That is, I get Requirement already satisfied when trying to pip install numpy.
The yum install command recommended on the SciPy install page completed fine but did not help, probably because this python version is installed at a non-default location.
Same result after building blas and lapack from source as described here
How do I get scipy to install properly?
Thx
I think you don't have lapack/blas library.
try this.
yum install python-devel python-nose python-setuptools gcc gcc-gfortran gcc-c++ blas-devel lapack-devel atlas-devel
it will install all what you need.
If you use Anaconda/miniconda, then use the conda package manager, not pip:
conda install scipy.
Value of a Peace of mind once starting always from a [Defined state]
There are many issues with pip / yum installer strategies that we, mortals, can spend ages on our attempts to get resolved.
Since I started to use the Travis Oliphant's Anaconda fully-fledged package-manager, these dependency-related / version-colliding issues simply disappeared. Well did not disappear, but principally do not appear.
Why?
Anaconda package-manager both allows one to keep separate versions ready / reconfigurable via Anaconda for individual python launches
and
Anaconda resolves updates in a smart way, one would never experience with manual/semi-manual pip/yum installers
In other words, if you strive to get rid of issues, opt to install Anaconda and start using it's (parallel) multi-versions installation / setup controls and it's smart package-manager facilities.
n.b.: this is not a commercial/spam/PR, this is just personal experience after many years of troubles with individual package updates' collisions / compatibility back-testing troubles in multi-py 2.5 / 2.6 / 2.7 installations environments

Install Spatialite for python (GeoDjango) on OS X

I am tearing my hair out trying to install Spatialite for GeoDjango!
I am already using Homebrew, it's generally easy and convenient so I initially tried to follow the Homebrew instructions for GeoDjango.
But this stops short of installing any database, i.e. Spatialite. The next step is to try and install Spatialite itself, but there are no Homebrew-specific instructions provided by Django docs.
I found this tutorial which looks perfect - a Homebrew and virtualenv-friendly install of Spatialite for GeoDjango.
But it doesn't work... it appears that my pysqlite is linked against the non-spatial-enabled version of SQLite that comes with OS X, rather than the Spatial-ised one I installed from Homebrew, I get this error when Django tried to connect to the db:
"The pysqlite library does not support C extension loading. Both SQLite and pysqlite must be configured to allow the loading of extensions to use SpatiaLite."
The author of pysqlite hasn't responded to my pleas for help on Github and I haven't found anything via Google.
So I went back to the drawing board and decided to follow the "Mac OS X-specific instructions" in the GeoDjango docs... by installing the various geo libs from the KyngChaos binary packages.
The docs say "Install the packages in the order they are listed above" but I found I couldn't install UnixImageIO without installing PROJ first. The link in the docs to download Spatialite binaries (http://www.gaia-gis.it/spatialite-2.3.1/binaries.html) is broken so I used the "Spatialite Tools v4.1" from KyngChaos instead.
Proceeding to the next step I get this error:
$ spatialite geodjango.db "SELECT InitSpatialMetaData();"
SQLite header and source version mismatch
2013-10-17 12:57:35 c78be6d786c19073b3a6730dfe3fb1be54f5657a
2013-09-03 17:11:13 7dd4968f235d6e1ca9547cda9cf3bd570e1609ef
Not really sure what's wrong at this point.
There is someone else here on SO who has gone the KyngChaos route and just ends up with the same "Both SQLite and pysqlite must be configured to allow the loading of extensions" error I got from the Homebrew route anyway.
I found this ticket #17756 for adding pyspatialite support to Django - pyspatialite is supposed to be an easier way to pip install everything but unfortunately it doesn't work either (see comments towards bottom of ticket).
I'm a bit reluctant to start trying to build everything from source by hand as it seems likely I'll just run into the same problems again, but spending hours Googling for info about cryptic compiler errors, magic flags and paths etc along the way.
I'm about ready to give up and just use Postgres/PostGIS.
I was able to get this working now, using the tip here:
https://github.com/ghaering/pysqlite/issues/60#issuecomment-50345210
I'm not sure if it was using the real paths that fixed it, or just the Homebrew kegs or underlying packages have been updated and now install cleanly. Still, it works now.
I reproduce below the steps I took:
brew update
brew install sqlite # 3.8.5
brew install libspatialite # 4.2.0
brew install spatialite-tools # 4.1.1
git clone https://github.com/ghaering/pysqlite.git
cd pysqlite
(where brew reported I had existing versions I unlinked them and installed the latest as commented above)
then edited setup.cfg to comment out #define=SQLITE_OMIT_LOAD_EXTENSION and specify the paths:
include_dirs=/usr/local/opt/sqlite/include
library_dirs=/usr/local/opt/sqlite/lib
activated the virtualenv where I want it installed, then
python setup.py build
python setup.py install
(build_static still fails with clang: error: no such file or directory: 'sqlite3.c')
(maybe I should have done pip install . as suggested in the github issue)
now the spatialite geodjango.db "SELECT InitSpatialMetaData();" succeeds, albeit with an ignorable error:
InitSpatiaMetaData() error:"table spatial_ref_sys already exists"
i.e. it's probably not even necessary to run that command
When I was istalling this i follow this instructions https://docs.djangoproject.com/en/dev/ref/contrib/gis/install/spatialite/#pysqlite2
pysqlite2
If you’ve decided to use a newer version of pysqlite2 instead of the sqlite3 Python stdlib module, then you need to make sure it can load external extensions (i.e. the required enable_load_extension method is available so SpatiaLite can be loaded).
This might involve building it yourself. For this, download pysqlite2 2.6, and untar:
$ wget https://pypi.python.org/packages/source/p/pysqlite/pysqlite-2.6.3.tar.gz
$ tar xzf pysqlite-2.6.3.tar.gz
$ cd pysqlite-2.6.3
Next, use a text editor (e.g., emacs or vi) to edit the setup.cfg file to look like the following:
[build_ext]
#define=
include_dirs=/usr/local/include
library_dirs=/usr/local/lib
libraries=sqlite3
#define=SQLITE_OMIT_LOAD_EXTENSION
I had the same error: SQLite header and source version mismatch.
For me it was enough to update libsqlite3-dev.
After that invoking $ spatialite geo.db "SELECT InitSpatialMetaData();" creates proper database.