I use Anaconda, Jupyter Notebook and have installed the latest version of Python 3.9.4.
After installing Python and Anaconda (anaconda3), I proceeded to install some libraries via the following command pip install pandas scikit-learn graphviz
, which however turned out to be unnecessary getting Requirement already satisfied
.
This is the problematic code that is causing me problems:
In [1]:
# standard libraries
import pandas as pd
import numpy as np
import statistics
import matplotlib.pyplot as plt
import matplotlib.image as mpimg
import pydotplus #<---------------------------------------------ModuleNotFoundError: No module named 'pydotplus'
from sklearn.preprocessing import MinMaxScaler
from math import log
from six import StringIO
from graphviz import Source #<----------------------------------ModuleNotFoundError: No module named 'graphviz'
import graphviz as gr #<----------------------------------------ModuleNotFoundError: No module named 'graphviz'
#from IPython.display import SVG
#from IPython.display import display
#from IPython.core.display import SVG
from IPython.display import Image
%matplotlib inline
#%pylab inline
from sklearn.feature_selection import mutual_info_classif
# pca libraries
from sklearn import decomposition
from sklearn.feature_selection import VarianceThreshold
from sklearn.preprocessing import scale
from sklearn.decomposition import PCA
#import seaborn as sb
# kfold stratification libraries
from sklearn.model_selection import StratifiedKFold
# libraries for building classifiers
from sklearn.ensemble import RandomForestClassifier
from sklearn import tree
from sklearn.model_selection import train_test_split
# libraries for evaluation metrics
from sklearn.metrics import f1_score
from sklearn.metrics import accuracy_score
from sklearn.metrics import balanced_accuracy_score
from sklearn.metrics import recall_score
from sklearn.metrics import precision_score
from sklearn.model_selection import cross_val_score
from sklearn.model_selection import cross_validate
from sklearn.metrics import confusion_matrix
from sklearn.metrics import classification_report
from datetime import datetime
from os import system
#from simple_colors import *
import bisect
import time
import sys
# import warnings filter
from warnings import simplefilter
# ignore all future warnings
simplefilter(action='ignore', category=FutureWarning)
# elimination of the conversion warning
import warnings
from sklearn.exceptions import DataConversionWarning
simplefilter(action='ignore', category=DataConversionWarning)
warnings.filterwarnings('error')
In [2]:
#dataframe import
#command parameters:
#filepath_or_buffer : str, pathlib.Path, py._path.local.LocalPath or any object with a read() method (such as a file handle or StringIO) The string could be a URL. Valid URL schemes include http, ftp, s3, and file. For file URLs, a host is expected. For instance, a local file could be file ://localhost/path/to/table.csv
#na_values : scalar, str, list-like, or dict, default None, Additional strings to recognize as NA/NaN.
#low_memory : boolean, default True Internally process the file in chunks, resulting in lower memory use while parsing, but possibly mixed type inference. To ensure no mixed types either set False, or specify the type with the dtype parameter. Note that the entire file is read into a single DataFrame regardless, use the chunksize or iterator parameter to return the data in chunks. (Only valid with C parser)
def loadData(path):
dataset=pd.read_csv(path, na_values=['Infinity'],low_memory=False)
return dataset
Initially, for some absurd reason, in the first part of the code, in correspondence of the arrows I get those errors:
ModuleNotFoundError: No module named 'pydotplus'
ModuleNotFoundError: No module named 'graphviz'
although the necessary libraries are already installed. For further verification, I ran the following commands from the terminal:
pip install graphviz
pip install pydotplus
And as I already expected, I get Requirement already satisfied
Nevertheless, I still tried to comment the code at the errors, but when I try to execute the first part (and later, also the second one), my Kernel freezes, displaying In [*]:
How to resolve this situation?
UPDATE:
If it can help someone to get to the solution and solve the problem, I realized that the Kernel freezes only after running the imports, that is only the first block of code. However, the problem remains unsolved, because I need to import these libraries for my code to work (and don't let the Kernel freeze).
from The Kernel freezes with the import of the libraries in Python
No comments:
Post a Comment