user3639207
user3639207

Reputation: 67

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?

Upvotes: 5

Views: 12793

Answers (4)

Conner Brown
Conner Brown

Reputation: 1

Change your Python Version

  1. Go to https://www.python.org/downloads/windows/, control-f search 3.7.9 and use the webinstaller. Follow all the recommended instructions
  2. In pyvenv.cfg in your project directory switch version number to 3.7.9 and home to C:.....\Python37.
  3. pip3 install alpaca-backtrader-api

Upvotes: 0

Yam Shargil
Yam Shargil

Reputation: 563

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!

Upvotes: 1

marisano
marisano

Reputation: 591

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

Upvotes: 2

Mike Müller
Mike Müller

Reputation: 85532

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.

Upvotes: 6

Related Questions