Watson Studio ImportError:没有名为'pydotplus'的模块

问题描述 投票:0回答:1

使用:Watson Studio Python 3.5使用Spark Python Notebook:https://gist.github.com/anonymous/ea77f500b4fd80feb69fadb470fca235

这部分给出了错误:

from IPython.display import Image  
import pydotplus
dot_data = tree.export_graphviz(regr, out_file=None, feature_names = X_train.columns.values ,filled=True)  
graph = pydotplus.graph_from_dot_data(dot_data)  

给出错误:ImportError:没有名为'pydotplus'的模块

解决方案是否有其他环境实际安装了此模块?或者有没有办法将此python模块安装/添加到现有的运行时?

ibm-watson watson-studio
1个回答
1
投票

在IBM Cloud文档中找到了答案。

https://dataplatform.cloud.ibm.com/docs/content/wsj/analyze-data/importing-libraries.html

在Apache Spark上安装自定义库和包上次更新时间:2019年3月1日2

当您将Apache Spark与Watson Studio中的笔记本关联时,会包含许多预安装的库。在安装库之前,请检查预安装的库列表。从笔记本单元格运行适当的命令:

Python: !pip list --isolated
R: installed.packages()

如果未列出所需的库,或者您要在笔记本中使用Scala库,请使用以下各节中的步骤进行安装。库包的格式取决于编程语言。使用Scala库

Scala笔记本的库通常打包为Java™归档(JAR)文件。暂时缓存库

Scala笔记本的库未安装到Spark服务。相反,它们在下载时被缓存,并且仅在笔记本运行时可用。

To use a single library without dependencies, from a public web server:
    Locate the publicly available URL to the library that you want to install. If you create a custom library, you can post it to any publicly available repository, such as GitHub.

    Download the library you want to use in your notebook by running the following command in a code cell:

     %AddJar URL_to_jar_file  

To use a library with dependencies, from a public Maven repository:

    Add and import a library with all its dependencies by running the following command. You need the groupId, artifactId, and version of the dependency. For example:

     %AddDeps org.apache.spark spark-streaming-kafka_2.10 1.1.0 --transitive

永久安装库

如果要将文件提供给spark-submit作业和Scala内核,或者想要通过其他内核的Java桥访问文件,例如使用JDBC驱动程序,可以将库永久安装到〜/ data / libs /来自Python或R.

安装库〜/ data / libs /的文件路径因库所需的Scala版本而异:

Use ~/data/libs/ for libraries that work with any Scala version.
Use ~/data/libs/scala-2.11/ for libraries that require Scala 2.11. The Scala kernel for Spark 2.1 uses Scala 2.11.

要安装库:

Locate the publicly available URL to the library that you want to install.

Download the library you want to install permanently into ~/data/libs/ by running the following command in a Python notebook:

 !(cd ~/data/libs/ ; wget URL_to_jar_file)

安装Python库

Use the Python pip package installer command to install Python libraries to your notebook. For example, run the following command in a code cell to install the prettyplotlib library:

 !pip install --user prettyplotlib

The --user flag installs the library for personal usage rather than the global default. The installed packages can be used by all notebooks that use the same Python version in the Spark service.
Use the Python import command to import the library components. For example, run the following command in a code cell:

 import prettyplotlib as ppl

Restart the kernel.

加载R包

Use the R install.packages() function to install new R packages. For example, run the following command in a code cell to install the ggplot2 package for plotting functions:

 install.packages("ggplot2")

The imported package can be used by all R notebooks running in the Spark service.

Use the R library() function to load the installed package. For example, run the following command in a code cell:

 library("ggplot2")

You can now call plotting functions from the ggplot2 package in your notebook.
© www.soinside.com 2019 - 2024. All rights reserved.