Why Is Matplotlib Failing On Import Matplotlib.pyplot As Plt
I installed matplotlib using conda: conda install matplotlib The following code failed: #!/usr/bin/env python import matplotlib import matplotlib.pyplot as plt With this error m
Solution 1:
Normally conda
isn't added to your path (it asks you during the installation if it should do that but the default is "no"), so the default python
will be the systems Python 2 (you start Python 3 with python3
).
You could verify this by using:
$ which python
That will return the path associated with the python
command. Likely this will return the path to the systems Python 2 "installation".
For example on my Ubuntu machine the commands which python
and which python3
return:
usr/bin/python (starts Python 2.7.12)
usr/bin/python3 (starts Python 3.5.2)
While my conda installation is somewhere in the /home/michael/miniconda
directory.
There are several options how you could use the conda
Python:
- Temporarily add the conda directory it to the PATH. (See for example How to add [...] to path)
- Permanently add the conda directory to the PATH. (see for example How to add a directory to the path)
- Use the
anaconda promt
which gives you a terminal with the conda directory prepended to the PATH.
Post a Comment for "Why Is Matplotlib Failing On Import Matplotlib.pyplot As Plt"