ipython notebook not finding mathplotlib module - macos

This is what I see when I try to import mathplotlib
In [11]:
import numpy as np
import mathplotlib.pyplot as plt
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-11-d33586aa69ae> in <module>()
1 import numpy as np
----> 2 import mathplotlib as plt
ImportError: No module named mathplotlib
I am not sure it is relevant but in other forums people talk about their .bashrc files.
Lindas-iMac:~ iMacLinda$ cat .bashrc
export PATH="/Users/iMacLinda/anaconda/bin:$PATH"
Matplotlib is definitely installed
Lindas-iMac:~ iMacLinda$ conda list | grep matplo
matplotlib 1.4.3 np110py27_3
I have done the following updates
conda update ipython 
conda update ipython-notebook 
conda updata ipython-qtconsole 
Does anyone have a solution to this?

sorry the problem was a typo. It should be matplotlib and not mathplotlib

Related

ImportError: DLL load failed while importing cv2: The specified module could not be found. in jupyter tried almost all but didnt work

Code
import numpy as np
import cv2
import os
import random
import matplotlib.pyplot as plt
import pickle
Error:
ImportError Traceback (most recent call last)
Input In [13], in <cell line: 2>()
1 import numpy as np
----> 2 import cv2
3 import os
4 import random
ImportError: DLL load failed while importing cv2: The specified module could not be found.
tried:
pip install opencv-contrib-python
pip install opencv_python‑3.2.0‑cp36‑cp36m‑win_amd64.whl (64-bit version)
I'm using anaconda nothing works struggling for a week

How to troubleshoot seaborn legend_out not working correctly with catplot or relplot?

With seaborn 0.11.1 and matplotlib 3.3.4 this...
import matplotlib as mpl
from matplotlib import pyplot as plt
print(sns.__version__, mpl.__version__)
import seaborn as sns
sns.set_theme(style="ticks")
exercise = sns.load_dataset("exercise")
g = sns.catplot(x="time", y="pulse", hue="kind", data=exercise)
plt.show()
...the result is supposed to look like this:
However, when I do that in JupyterLab or Plotly-Dash I get:
I deleted ~/.config/matplotlib and setup a clean conda environment with minimal packages. Same result.
plt.rcParams['figure.autolayout'] = False
fixes it.

after installing seaborn, import fails to find it

I've tried installing seaborn under anaconda on my mac. I've tried following many different instructions.
It installs with no problem but "import seaborn" fails.
I'm using Python 2.7 here. It will work for me under Python 3 but unfortunately I'm taking a course in which the notebooks are Python 2.7.
import seaborn
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-1-085c0287ecb5> in <module>()
----> 1 import seaborn
ImportError: No module named seaborn

Numpy and Pandas Not Working in Jupyter Notebook on Mac

I have both Python 2.7 and 3.6 working on my machine. Numpy and Pandas both load, for either version of Python, in the terminal. However, when I try to access them from inside Jupyter notebook, I get the following error messages:
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-2-4ee716103900> in <module>()
----> 1 import numpy as np
ModuleNotFoundError: No module named 'numpy'
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-1-af55e7023913> in <module>()
----> 1 import pandas as pd
ModuleNotFoundError: No module named 'pandas'
Here is a screenshot of the problem as well:
If you look in the top right hand corner of the screenshot, you will notice where it says "Python3". I have seen video tutorials on Jupyter where clicking on that button generates a drop down list, allowing users to select alternate versions of Python. However, when I click on that button, nothing happens.
I noticed that a similar question was asked before here:
numpy & pandas 'ModuleNotFoundEror' in Jupyter notebook (Python 3)
However, very little information was provided and no resolution seems to have been found.
Another similar question provided a hint at an answer that was slightly more promising. It suggested running the following code both from terminal and from inside Jupyter, to make sure they match.
import sys; sys.executable
failed to import numpy as np when I worked with jupyter notebook
From terminal using Python 2.7.10>>
import sys; sys.executable
'/usr/bin/python'
From terminal using Python 3.6.1>>
import sys; sys.executable
'/usr/local/bin/python3'
From Jupyter>>
'/Library/Frameworks/Python.framework/Versions/3.6/bin/python3.6'
Have you checked this solution:
Failure to import numpy in Jupyter notebook ?
In your Jupyter screenshot, you're using a Python 3 kernel.
Make sure you have NumPy (and any others you might want to use) installed in your selected Python 3 environment.

Version upgrade to scikit-learn

I wanted to do LDA on some data and so followed this example:
http://scikit-learn.org/stable/auto_examples/decomposition/plot_pca_vs_lda.html#example-decomposition-plot-pca-vs-lda-py
however, on trying:
from sklearn.discriminant_analysis import LinearDiscriminantAnalysis
I got an import error. Huh, maybe this is a new function, I thought. So I updated scikit-learn via conda from 0.15.2 to 0.17. But now I can't even import sklearn:
import sklearn
RuntimeError: module compiled against API version a but this version of numpy is 9
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "//anaconda/lib/python2.7/site-packages/sklearn/__init__.py", line 57, in <module>
from .base import clone
File "//anaconda/lib/python2.7/site-packages/sklearn/base.py", line 9, in <module>
from scipy import sparse
File "//anaconda/lib/python2.7/site-packages/scipy/sparse/__init__.py", line 213, in <module>
from .csr import *
File "//anaconda/lib/python2.7/site-packages/scipy/sparse/csr.py", line 13, in <module>
from ._sparsetools import csr_tocsc, csr_tobsr, csr_count_blocks, \
ImportError: numpy.core.multiarray failed to import
I tried updating numpy and scipy using both pip and conda to no avail. I then tried a complete clean re-install of anaconda by:
rm -rf ~/anaconda
and a subsequent download of the .pkg from http://docs.continuum.io/anaconda/install#anaconda-install
Still I get the same error. Here are my OS and package details:
Mac OSX 10.5.2
bash-3.2$ conda -V
conda 3.18.6
scipy==0.16.0
numpy==1.9.1
scikit-learn==0.17
The last of these via pip freeze since I can't import it. I'm going nuts here. Any help much appreciated.
Try:
conda install numpy=1.10.1
I've had that module compiled against API version a but this version of numpy is 9 error before, and this solved it for me.

Resources