1

I have two python compilers on my Ubuntu 14.04 VM. I have installed matplotlib as

pip install matplotlib

But the matplotlib cannot be used from python3.It can be used from python2.7

If I use import matplotlib.pyplot as plt inside my script test.py and run it as

python3 test.py I get the error

ImportError: No module named 'matplotlib'

How can this be fixed.

2
  • Modules have to be installed separately for Python 2 and 3. Installing a module for Python 2 doesn't install it for Python 3. Commented Nov 12, 2015 at 21:08
  • Why would you do that (installing with pip) instead of installing the package from your distro? Just curious... Commented Nov 13, 2015 at 8:26

2 Answers 2

3

Use pip3 to install it:

sudo apt-get install python3-pip
sudo pip3 install matplotlib
Sign up to request clarification or add additional context in comments.

Comments

1

You can install the package from your distro with:

sudo apt-get install python3-matplotlib

It will probably throw an error when you import matplotlib, but it is solved by installing the package tkinter with:

sudo apt-get install python3-tk

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.