ImportError: No module named mpl_toolkits - python

I have a python program and am trying to plot something using the mplot3d from mpl toolkits, but whenever I try to import the Axes3D from mpl_toolkits from mpl_toolkits.mplot3d import Axes3D
I get the following error: ImportError: No module named mpl_toolkits

I solved this by running the following imports in the following order:
import matplotlib.pyplot as plt
import mpl_toolkits
from mpl_toolkits.mplot3d import Axes3D
Note: This only worked for me on python3. So first, I had to install python3 and pip3. Then I did "pip3 install matplotlib" in Terminal. If you already have matplotlib then try "pip3 install --upgrade matplotlib"

Related

can't import seaborn on Jupyter notebook

I have installed numpy, pandas and matplot lib
but installation of seaorn i not possible. I ve tried updating Numpy, installing seaborn through the cmd command but in vain. I restarted the kernel each time.
import seaborn as sns
I keep recieving ;
ImportError: DLL load failed while importing _arpack: The specified procedure could not be found.
I have used:
!pip install seaborn
pip install numpy --upgrade --user
pip import seaborn as sns df = sns.load_dataset(penguins) sns.pairplot(df, hue=species)
It seems like your seaborn and/or numpy installation is broken or at least there is some versions conflict.
Try to run these commande from the command line :
pip unistall seaborn numpy
pip install mkl numpy seaborn
After that, you can run this code in your Jupyter notebook :
import seaborn as sns
df = sns.load_dataset("penguins")
sns.pairplot(df, hue="species")
the problem was fixed by updating matplotlib on the conda shell.
conda update matplotlib

ModuleNotFoundError: Pyramid

I'm trying to import these libraries:
from math import sqrt
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
from statsmodels.tsa.arima_model import ARIMA
from sklearn.metrics import mean_absolute_error, mean_squared_error
from pyramid.arima import auto_arima
from statsmodels.tsa.stattools import adfuller
But this error is coming again and again
ModuleNotFoundError: No module named 'pyramid'
I have tried pip install pyramid-arima but it's also throwing me so many errors in cmd.
Can anyone suggest to me what I can do to resolve this problem?
try
pip install pmdarima
pmdarima is the official new name for pyramid.arima.
Try to install pmdarima by using pip:
pip install pmdarima
I also needed to modify my python script to use:
from pmdarima.arima import auto_arima

How to Import Pandas Profiling [duplicate]

I am new to pandas_profiling and getting ImportError while importing it. Please help.
import numpy as np
import pandas as pd
import pandas_profiling
import matplotlib.pyplot as plt
import matplotlib.image as mpimg
%matplotlib inline
import seaborn as sns
After executing the above code in jupyter notebook, I am getting the following error.
ImportError: matplotlib is required for plotting when the default backend "matplotlib" is selected.
> python --version
Python 3.7.3
> pip list | grep -E "matplotlib|pandas"
matplotlib 3.2.0
pandas 0.25.3
pandas-profiling 2.5.3
I don't know the actual reason but I restarted the kernel and it is working.
Before restarting the kernel I executed following commands:
conda install -c anaconda pandas-profiling

Problem importing a module in PyCharm IDE

Hi I'm having problems trying to import a matplotlib module in PyCharm. It works when I do "import matplotlib", and "import matpolotlib.pyplot as plt" , but not when I try to "from matplotlib import style"
do NOT import matplolib import matplotlib
if not working try pip install matplotlib

Python: Imported matplotlib but cannot use imshow

I'm working in Ubuntu as Virtual-Box guest on top of Windows machine (as host), and I am attempting to run my python script from the terminal. I had difficulty installing matplotlib using pip install. I managed to install it using
sudo apt-get install python-matplotlib
However, I am unable to bring up an image I have created in my code:
import numpy as np
import matplotlib.pyplot as plt
import random as random
from random import randrange
image = plt.imshow(mymatrix)
plt.show()
If I import matplotlib as:
import matplotlib as plt
I am recieving the following error on attempting to run the script:
AttributeError: 'module' object has no attribute 'imshow'
If I import matplotlib as:
import matplotlib.pyplot as plt
I recieve the following error:
raise ImportError, str(msg) + ', please install the python-tk package'
ImportError: No module named _tkinter, please install the python-tk
package
On attempting to install python-tk using 'pip install python-tk' this is what I'm getting:
~/ising $ pip install python-tk Collecting python-tk Could not find
a version that satisfies the requirement python-tk (from versions: )
No matching distribution found for python-tk
I'm unsure if I have in fact incorrectly installed matplotlib from the beginning. I am aware pyplot is not automatically imported with matplotlib, could the same be true for installing it from the console? Seems like I have tried everything at this stage.
The problem appears to be that you do not have a graphical backend installed. The error you are getting about Python Tk is happening because normally Tk comes with any Python distribution, so you should have at least that. You can install any Python bindings for Tk, Pyqt4, Pyqt5, Wx, GTK, (possibly others) to get a working interactive graphical backend. Check the package repository for the actual package names to install.
Keep in mind that functions like imshow are part of the (sub)package matplotlib.pyplot, not matplotlib itself. import matplotlib as plt is simply wrong if you intend to do plt.imshow(...). The correct import is either from matplotlib import pyplot as plt or import matplotlib.pyplot as plt.
According to the documentation here try this
python -mpip install -U pip
python -mpip install -U matplotlib

Categories

Resources