I can't make plots on the colab with matplotlib - python

I recently had an error in google colab to make the plots I need. It pame returns the following error.
ImportError: cannot import name 'png' from 'matplotlib' (/usr/local/lib/python3.7/dist-packages/matplotlib/init_.py)
It seems that it is connected with the version of matplotlib, because I looked for this error on the internet and one of the solutions was:
!pip install matplotlib == 3.1.1
It works, but it doesn't make much sense when it comes to Colab

thanks for the codeļ¼š
!pip install matplotlib == 3.1.1
it work on my colan

Related

Plotly Figure not Working: NBformat installing problem

I'm starting to adventure into Plotly library.
I created, in VSCode, a simple figure to start analyzing, as follows:
import plotly
import plotly.graph_objects as go
fig=go.Figure(
data=[go.Bar(x=[1,2,3],y=[1,2,3])],
layout=go.Layout(
title=go.layout.Title(text='A figure specified by a graph object')
)
)
after applying fig.show() terminal shows the following error:
ValueError: Mime type rendering requires nbformat>=4.2.0 but it is not installed
I have already installed nbformat in Anaconta Prompt and update it as well, but I don't know why it isn't working.
I believe the solution is pretty straightforward.
pip install --upgrade nbformat
or
!pip install nbformat
or something along those lines of resetting the kernel. Others have encountered this problem before. Check out this link

How to fix RuntimeError: Bool type is not supported by dlpack

I have been using the following code to get the default Cora dataset provided by DGL, but the following error suddenly occurred today.
The code was runned in CoLab (python 3.7 and Pytorch backend). I believed this is a error from the DGL update (since it had worked all the time before). However, I just wonder if there is anything we can do on our end to fix this?
Thanks.
It seems that an error is from torch update to 1.10.0. Reinstalling torch to 1.9.1 works for me. You can reinstall torch in colab as follows:
!pip install dgl==0.6.1
!pip install torch==1.9.1
import dgl
cora = dgl.data.CoraGraphDataset()
installing the last GPU accelerated(cuda 11.1) dgl with pip install dgl-cu111 -f https://data.dgl.ai/wheels/repo.html

ModuleNotFoundError: No module named 'statsmodels' even after i have installed it in conda/python

enter code herethis is the image of pip where I installed statsmodels
[This is the error I get when I run the code below][2]
from statsmodels.tsa.seasonal import seasonal_decompose
from dateutil.parser import parse
df = pd.read_csv('https://raw.githubusercontent.com/selva86/datasets/master/a10.csv',parse_dates=['date'], index_col = 'date')
result_mul = seasonal_decompose(df['value'],model='multiplicative',extraplote_trend = 'freq')
result_add = seasonal_decompose(df['value'], model='additive',extrapolate_trend= 'freq')
plt.rcParams.update({'figure.figsize': (10,10)})
result_mul.plot().subtitle('Multiplicative Decompose', fontsize=22)
result_add.plot().subtitle('Additive Decompose', fontsize=22)
plt.show()
``
[2]: https://i.stack.imgur.com/hC9tg.png**these are the issues I have been facing please help me, anyone, I have posted my issue in the uploaded screenshots. I was not able to install statsmodels module even when It was installed it several times **
I think you have 0.11.1 version of statsmodels. However, import statsmodels worked in my Jupyter with statsmodels version 0.10.1 but please work on below points and let me know:
Use import statsmodels.api as sm , as recommended in https://www.statsmodels.org/stable/importpaths.html
If above doesn't help, please uninstall statsmodels and use the following command to re-install it: conda install -c anaconda statsmodels. It is recommended in https://anaconda.org/anaconda/statsmodels . After this, try to import.
This worked for me
pip install statsmodels or pip3 install statsmodels

Geopandas ImportError: The descartes package is required for plotting polygons in geopandas

I'am trying to run a simple geopandas code using ANACONDA spyder. However, I'am encountering an error.
I have included the code and the error as below:
--
here is the code:
import geopandas as gpd
world = gpd.read_file(gpd.datasets.get_path('naturalearth_lowres'))
world.plot()
import matplotlib.pyplot as plt
plt.show()
--
here is the error:
File "C:\Users\usr\Anaconda3\lib\site-packages\geopandas\plotting.py", line 90, in plot_polygon_collection
"The descartes package is required for plotting polygons in geopandas."
ImportError: The descartes package is required for plotting polygons in geopandas.
--
I checked online and I couldn't find troubleshooting solution for this problem. Can anyone please help and advise?
appreciated.
Depending on your package manager install descartes. In anaconda prompt do the following:
conda install descartes
Replace conda with pip or an other package manager of your use.
The above didn't work for me. I ran the below command instead and it worked:
pip install descarteslabs[complete]
Add --user on the end if you encounter any permissions errors

Jupyter Notebook: Importing SMOTE from imblearn - ImportError: cannot import name 'pairwise_distances_chunked'

I'm trying to use the SMOTE package in the imblearn library using:
from imblearn.over_sampling import SMOTE
getting the following error message:
ImportError: cannot import name 'pairwise_distances_chunked'.
Here is a screenshot of my import screenshot of download confirmation
Really stumped on this, any guidance would be greatly appreciated.
I have encountered a similar problem.
I could solve by opening a new IPython console.
I know it's a bit late, but for anyone using Jupyter notebook, I could solve my problem by just restarting the kernel.
Link:
ImportError: cannot import name check_array from sklearn.utils.validation
Re-installing the package solved the issue.
conda install -c conda-forge imbalanced-learn
I opened a new console after re-install Scikit-learn
(python3 -m pip install -U scikit-learn; in Jupyter notebook), then it works.

Categories

Resources