I am using Python 3.7.3 installed from Anaconda. It has installed Ipython: I can invoke Ipython from the command line and running the following code in Jupyter notebooks I can see the ipython as an installed package
import subprocess
import sys
reqs = subprocess.check_output([sys.executable, '-m', 'pip', 'freeze'])
installed_packages = [r.decode().split('==')[0] for r in reqs.split()]
print (installed_packages)
However in the same Jupyter notebook when I run the following code
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import pydotplus
from Ipython.display import Image
from sklearn.linear_model import LogisticRegression
from sklearn import tree
from sklearn.tree import DecisionTreeClassifier
from sklearn.decomposition import FactorAnalysis
from sklearn.cluster import KMeans
from sklearn.model_selection import train_test_split
from sklearn.metrics import confusion_matrix,accuracy_score,f1_score
I get the error returned : ModuleNotFoundError: No module named 'Ipython'
It's a Windows 10 machine. I tried reinstalling with conda install and conda update to no avail, and I tried variants of capitalisation.
You have a typo. The P in IPython is meant to be capitalized.
Use:
from IPython.display import Image
Related
```
!pip install mediapipe opencv-python
import mediapipe as mp
import cv2
import numpy as np
import uuid
import os
```
I used Jupiter Notebook to run this code
error:[1]: https://i.stack.imgur.com/sljDY.jpg
I have a problem with Google Colab, it crashes. When I try to import libraries, this system log appears:
WARNING:root:kernel 550fdef7-0cf5-47e7-86a7-8a6a019a6aaa restarted
KernelRestarter: restarting kernel (1/5), keep random ports
Kernel interrupted: 550fdef7-0cf5-47e7-86a7-8a6a019a6aaa
I looked for the answer in other posts and checked that the Ram was free (it is), but importing one library at a time I discovered that the problem is given by torch_geometric, what could I do? To install the libraries I use this code:
!pip install -q torch torchvision
!pip install torch-scatter torch-sparse torch-cluster torch- spline-conv torch-geometric -f https://data.pyg.org/whl/torch-1.10.0+cpu.html
!pip install import-ipynb
!pip install networkx
!pip install rdkit-pypi
!pip install deepchem
!pip install -q dgl
!pip install gdown -U --no-cache-dir
The libraries I'm trying to import are these:
# Usefull libreries to load and process the data
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
from sklearn.exceptions import ConvergenceWarning
from sklearn.metrics import accuracy_score
from sklearn.svm import LinearSVC
import import_ipynb
import warnings
import os
import os.path as osp
from tqdm import tqdm
# Usefull libresies to create and work on graph
import torch
import torch_geometric
import torch.nn.functional as F
from torch_geometric.loader import DataLoader
from torch_geometric import data
from torch_geometric.data import Data, Dataset, Batch
import torch_geometric.utils
from torch.nn import Linear, BatchNorm1d, ReLU, Sequential
import torch.nn.functional as F
from torch_geometric.nn import global_mean_pool, GCNConv, GINConv, WLConv, GAE
from torch_geometric.nn.glob.glob import global_mean_pool
import networkx as nx
# Useful libraries to visualize chemical structures and calculate chemical properties
import rdkit
from rdkit import Chem
from rdkit.Chem import Draw
from rdkit.Chem.rdMolDescriptors import CalcMolFormula
import deepchem as dc
# Notebook
from graph_converter import MoleculeDataset
from Utils import formula, draw_molecule, activity
Thanks to all!
I installed scikit-learn both using pip and conda commandas. Whenever I check the package, it shows that it is already installed but, whenever I try import it, it shows error.
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
from sklearn.model_selection import train_test_split
%matplotlib inline
ERROR:
---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-33-82d3fc6531ea> in <module>
3 import matplotlib.pyplot as plt
4 import seaborn as sns
----> 5 from sklearn.model_selection import train_test_split
6 get_ipython().run_line_magic('matplotlib', 'inline')
ModuleNotFoundError: No module named 'sklearn'
I have tried reinstalling it multiple times but it shows the same error
Make sure that if you install the sklearn package in the python version that you are working. For suppose if your system has two versions of python installed in it like both python 2 and python 3 then you have installed sklearn package in python 2 and executing your code in python 3 or vice-versa.
I think you don't have latest version of sklearn because in old version of sklearn
below code was not working.
from sklearn.model_selection import train_test_split
Please update your sklearn by following command
conda update scikit-learn
I got the same error while installing these.
What you can do is install all the packages using the command
conda install pandas
and all other packages similarly or all in once
conda install pandas numpy matplotlib scikit-learn
in your project directory.
And now you can open your jupyter notbook using command
jupyter notebook
in the same environment or I should say same project directory.
I am a total newbie in Python 3 and programming in general so I looked at other peoples code and just for the beginning paste one example into Jupyter. But right at the beginning, I get an Error "ModuleNotFoundError: No module named 'xgboost'" Why does this not work?
import pandas as pd
import numpy as np
import re
import sklearn
import xgboost as xgb // error
import seaborn as sns
import matplotlib.pyplot as plt
%matplotlib inline
import plotly.offline as py
py.init_notebook_mode(connected=True)
import plotly.graph_objs as go
import plotly.tools as tls
import warnings
warnings.filterwarnings('ignore')
# Going to use these 5 base models for the stacking
from sklearn.ensemble import (RandomForestClassifier, AdaBoostClassifier, GradientBoostingClassifier, ExtraTreesClassifier)
from sklearn.svm import SVC
from sklearn.cross_validation import KFold
I am assuming you are running Anaconda, because this is the first error you encountered. You need to install this package: https://anaconda.org/anaconda/py-xgboost because the code you copied uses it and needs it.
You will probably get a plotly error too, so install https://anaconda.org/plotly/plotly and remember to restart Jupyter (or the kernel at least).
If you are not running Anaconda, run pip install xgboost and pip install plotly.
I tried
pip install xgboost
and
pip3 install xgboost
But it doesn't work
##ModuleNotFoundError: No module named 'xgboost'
It worked in the Jupyter Notebook cell
import sys
!{sys.executable} -m pip install xgboost
Go to command prompt >> By typing "cmd" in your windows search engine.>> Please type "pip install xgboost".
Later, close your Jupyter notebook and open it again. Run the respective cell.
If you are still getting the error then :
Add a cell in Jupyter notebook and type "pip install xgboost". Run this cell. Now it will work.
Giving a very detailed answer since beginners might be here too. Hope this helps! Be motivated! You can do it!
conda install -c conda-forge xgboost
When I do pip freeze I see numpy and sklearn in my virtualenv. When
My runner.py consists of :
from preprocess import Data
def main():
pass
preprocess.py
from sklearn.preprocessing import RobustScaler
import numpy as np
I run jython runner.py I get the error:
from sklearn.preprocessing import RobustScaler
ImportError: No module named sklearn
Not sure why I can't find any of the packages I've installed.