Multiple errors importing and using mglearn - python

I'm getting multiple errors trying to install and import the mglearn library into a Jupyter notebook. I've installed mglearn using the command line using pip install mglearn and also directly into Jupyter using !pip install mglearn. However, when I try to import mglearn I get the error ModuleNotFoundError: No module named 'mglearn'. If I try to install it again I get a Requirement already satisfied response.
I then went into the python terminal with $python3 and tried import mglearn, which was successful. I checked the version and I get 0.1.7.
I've also tried the following code within Jupyter:
import sys
!{sys.executable} -m pip install mglearn
With that code I get a zsh:1: no matches found: error.
I know it's installed and I'm importing it. I'm out of ideas for how to fix this. Any help would be appreciated.

Related

Why do I get 'No module named 'currency-symbols' when importing xls2xlsx, even though 'pip install currency-symbols' returns requirement satisfied?

My IDE is Spyder and the distribution I am using is miniconda. I use pip install in the anaconda prompt window (as I usually do).
'pip install xls2xlsx' seems to run fine and install the package.
When I try 'from xls2xlsx import XLS2XLSX' I get the following error:
ModuleNotFoundError: No module named 'currency-symbols'
If I try 'pip install currency-symbols' , I get:
'Requirement already satisfied: currency-symbols in c:\users\user\miniconda3\lib\site-packages (2.0.2) '
I can see both directories in the site-packages directory.
So I had the same or very similar problem, my trace-back said it could not import currency_symbols. I found that the module it was trying to import was the constants from that package. So I went into the py file where xls2xlsx had the issue
"htmlxls2xlsx.py" my traceback said line 40..
currency_symbols_constants =
importlib.import_module('currency-symbols.constants')
I noticed this was part of an 'exception' so I fixed line 37 from import currency_symbols.constants as currency_symbols_constants to import currency_symbols._constants as currency_symbols_constants
Now it imports just fine.
I also had version 2.0.2 of currency-symbols installed, but my working host was using 2.0.1. I discovered that if you install 2.0.1, the issue did not occur.
pip3 install -Iv currency-symbols==2.0.1

ImportError: cannot import name 'DecisionBoundaryDisplay' from 'sklearn.inspection'

I imported sklearn DecisionBoundaryDisplay via the below command in my Google Colab file.
from sklearn.inspection import DecisionBoundaryDisplay
And I'm getting the following error.
ImportError: cannot import name 'DecisionBoundaryDisplay' from 'sklearn.inspection'
I even installed the following packages & also tried by restarting my runtime but still I'm getting the error.
!pip install --upgrade scikit-learn
!pip install scipy
!pip3 install -U scikit-learn scipy matplotlib
How to fix this issue?
what worked for me was installing scikit learn 1.1.0, i had version 1.0.2 before and got the same error you're encountering.
pip install -U scikit-learn --user
Hope it helps.
It seems DecisionBoundaryDisplay is a new feature and it is currently in an unstable development version. To use it, you need to install the nightly build.

ModuleNotFoundError: No module named 'flair'

I have installed flair library via the following command
!pip install flair
but when i tries to import it, it will generate error like "ModuleNotFoundError: No module named 'flair'"
Code:
import torch
import numpy as np
from flair.data import Sentence
from flair.embeddings import TransformerDocumentEmbeddings
install via the following command make sure you use --user option otherwise you will get a permission error in windows 10.
!pip install --user flair
after install flair you have to restart kernel in jupyter notebook

ModuleNotFoundError: No module named 'ipytest.magics'

I am new to Jupyter notebook, and while trying to run the following code:
import sys
!{sys.executable} -m pip install pytest
!{sys.executable} -m pip install ipytest
import ipytest.magics
import pytest
I ran into the ModuleError. None of the code above that caused any problems. What is the reason for this, and what can I do to solve it?
(My Python version is 3.7.4)
I met the same problem. I checked the latest document of ipytestipytest document 0.9.1, it changed the sytle of writing, so i also changed. You can try
import ipytest
import pytest
ipytest.autoconfig()

Cannot import or install pandas-profiling in Jupyter Notebook

I have technically already installed pandas-profiling using
pip install pandas-profiling
But when I try to import it, I get the following error:
import numpy as np
import pandas as pd
import pandas_profiling
---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-1-e1a23f2a6f04> in <module>()
1 import numpy as np
2 import pandas as pd
3 import pandas_profiling
ModuleNotFoundError: No module named 'pandas_profiling'
First Error Image
So I tried installing it in Jupyter Notebook and got the following error as well:
import sys
!{sys.executable} -m pip install pandas-profiling
Collecting pandas-profiling
Could not find a version that satisfies the requirement pandas-profiling
(from versions: )
No matching distribution found for pandas-profiling
Second Error Image
I am also unable to install it using conda for both as I am unable to establish a connection to conda.anaconda.org for some reason.
To others who are looking to resolve this issue try these alternate steps :
Run pip install pandas-profiling command in a separate cell in the jupyter notebook.
After this just restart the kernal and run again. This should definitely work. Worked for me.
Based on the comments I was able to figure out the issue. I had to install jupyter notebook outside of the Anaconda root env and open it from the terminal.
pip3 install jupyter notebook
Once I did that it imported properly.
Steps:
Download the ZIP
Open Anaconda Prompt and go to the directory and extract the files to a folder
cd
C:\Users\farah\Downloads\pandas-profiling-master\pandas-profiling-master
Then type python setup.py install
Now you can use:
import pandas_profiling as pp
df = pd.read_csv('1234.csv')
pp.ProfileReport(df)
Reference: Pandas profiling
!pip install pandas_profiling # Run this from Jupytor notebook Ignore the warnings if any
from pandas_profiling import ProfileReport #restart the kernel if throws error
ProfileReport(df)
Note: This worked for me on Windows 10
From Anaconda Prompt:
conda install -c conda-forge pandas-profiling

Categories

Resources