【发布时间】:2021-07-04 12:19:44
【问题描述】:
我使用 Anaconda、Jupyter Notebook 并安装了最新版本的 Python 3.9.4。
安装 Python 和 Anaconda (anaconda3) 后,我继续通过以下命令 pip install pandas scikit-learn graphviz 安装一些库,但结果证明没有必要获取 Requirement already satisfied。
这是导致我出现问题的有问题的代码:
在 [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')
在[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
最初,出于某种荒谬的原因,在代码的第一部分,对应于箭头,我得到了这些错误:
ModuleNotFoundError: No module named 'pydotplus'
ModuleNotFoundError: No module named 'graphviz'
尽管已经安装了必要的库。为了进一步验证,我从终端运行了以下命令:
pip install graphviz
pip install pydotplus
正如我已经预料的那样,我得到了Requirement already satisfied
尽管如此,我仍然尝试在错误处注释代码,但是当我尝试执行第一部分(以及稍后,第二部分)时,我的内核冻结,显示 In [*]:强>
如何解决这种情况?
更新:
如果它可以帮助某人找到解决方案并解决问题,我意识到内核仅在运行导入后才会冻结,这只是第一块代码。但是,问题仍未解决,因为我需要导入这些库才能使我的代码正常工作(并且不要让内核冻结)。
【问题讨论】:
-
可能又是一个PATH问题,我认为关于python找不到点的这类问题有很多问题。
-
我已经阅读了有关 PATH 问题的信息,但是在安装此版本时,它并没有要求我禁用 PATH 长度限制。我也尝试下载旧版本,但此功能已被删除
-
可能在谈论一些不同的东西,我在谈论系统路径。你重启终端了吗?
-
当然,但没有任何改变
-
考虑到您已经安装了 Anaconda,我建议您使用
conda安装软件包以避免许多安装和依赖问题。
标签: python anaconda graphviz pydotplus