User1551892
User1551892

Reputation: 3364

How to install Matplotlib for anaconda 1.9.1 and Python 3.3.4?

I am configuring Anaconda 1.9.1 together with Python 3.3.4 and I am unable to setup Matplotlib for anaconda environment when I try to add package using Pycharm. I also tried to install from Matplotlib.exe file which I downloaded from its website. I can not change the installation directory in that case. I would like to know that is there a way to tackle this issue.

Upvotes: 3

Views: 45733

Answers (3)

Mona Jalal
Mona Jalal

Reputation: 38155

conda install -c conda-forge matplotlib

Upvotes: 2

fantabolous
fantabolous

Reputation: 22716

Assuming you've already installed a 3.x python env in anaconda, this one line should do the trick:
conda install matplotlib -n name
where name is the name you previously gave to your python 3 anaconda env. If you're not sure of the name you gave it, it will be the name of a subdir in the Anaconda\envs directory.

Background: I recently went through the same trouble with matplotlib not getting installed by default by anaconda when I added a full python 3 env, even though it's meant to. The above line solved it for me; it gave me the following warnings so it seems likely that the two different available versions caused it to initially install neither. However it allowed me to choose the one I wanted, and then everything worked great.

Warning: 2 possible package resolutions:
[u'dateutil-2.1-py33_2.tar.bz2', u'matplotlib-1.3.1-np18py33_1.tar.bz2', u'numpy-1.8.0-py33_0.tar.bz2', u'pyparsing-2.0.1-py33_0.tar.bz2', u'pyside-1.2.1-py33_0.tar.bz2', u'python-3.3.5-0.tar.bz2', u'pytz-2013b-py33_0.tar.bz2', u'six-1.6.1-py33_0.tar.bz2']
[u'dateutil-2.1-py33_2.tar.bz2', u'matplotlib-1.3.1-np17py33_1.tar.bz2', u'numpy-1.7.1-py33_3.tar.bz2', u'pyparsing-1.5.6-py33_0.tar.bz2', u'pyside-1.2.1-py33_0.tar.bz2', u'python-3.3.5-0.tar.bz2', u'pytz-2013b-py33_0.tar.bz2', u'six-1.6.1-py33_0.tar.bz2' ]

Upvotes: 5

Paul H
Paul H

Reputation: 68146

If you're using anaconda, your default environment is Python 2.7. You need to create a new environment and install matplotlib in there.

In a command prompt, do the following (saying yes to the questions):

conda create --name mpl33 python=3.3 matplotlib ipython-notebook
activate mpl33
ipython notebook

You should be able to import matplotlib when the notebook server comes up.

  • The first command simultaneously creates the environment and install the listed packages.
  • The second command activates the new environment by prepending its location to the system path
  • The third command just starts the ipython notebook so that you can test out everything

I don't know how pycharm works, but my guess is that you'll have to tell it to look for the right python that you want to use. In this case it'll be something like: C:/Users//anaconda/envs/mpl33. In any case, the command prompt should display the path when you activate the environment.

Once you've activated your environment, you can install more packages like this:

conda install pandas=0.12
conda install pyodbc statsmodels

You can specific version numbers of packages like the first command or simply accept the latest available version (default)

Upvotes: 5

Related Questions