On Ubuntu 14.04, Python 3.4.3.
cd /path/to/your/project
sudo apt-get install python3.4-venv libfreetype6-dev python3-tk
python3 -m venv pyplot
source ./pyplot/bin/activate
pip install --upgrade setuptools # optional?
pip install matplotlib
Verify installation:
cd /path/to/your/project/pyplot
cat << EOF > plot.py
import matplotlib.pyplot as plt
plt.plot([1,23,2,4])
plt.ylabel('some numbers')
plt.show()
EOF
source ./pyplot/bin/activate
python plot.py
Use matplotlib in shell script:
cat << EOF > plot.sh
#!/bin/bash
source /path/to/your/project/pyplot/bin/activate
python /path/to/your/project/plot.py
EOF
chmod 755 plot.sh
./plot.sh
Ref:
- http://stackoverflow.com/questions/25674612/ubuntu-14-04-pip-cannot-upgrade-matplotllib
- http://stackoverflow.com/questions/11425106/python-pip-install-fails-invalid-command-egg-info
- http://stackoverflow.com/questions/8605847/how-to-install-matplotlib-with-python3-2
- http://stackoverflow.com/questions/36327134/matplotlib-error-no-module-named-tkinter