简体   繁体   English

如何在 OnDemand Jupyter Notebook 中导入非标准 python 模块

[英]How do I import a non-standard python module in an OnDemand Jupyter Notebook

I am using the OnDemand service on my University HPC website to run a remote Jupyter Notebook.我在我的大学 HPC 网站上使用 OnDemand 服务来运行远程 Jupyter Notebook。 I have access to all the standard modules (such as numpy ).我可以访问所有标准模块(例如numpy )。 But I also need to import a non-standard module that IS installed on my remote machine (in a specific conda environment) but doesn't seem to be available on the OnDemand notebook (when I try to import it).但是我还需要导入一个安装在我的远程机器上(在特定的conda环境中)但在 OnDemand 笔记本上似乎不可用的非标准模块(当我尝试import它时)。

Am I able to import the module from the correct conda environment somehow, perhaps by specifying the path of the module on my machine or something like that?我是否能够以某种方式从正确的conda环境import模块,也许是通过在我的机器上指定模块的路径或类似的东西?

Or maybe I need to install the module again whilst I am within the OnDemand notebook?或者,当我在 OnDemand 笔记本中时,我可能需要再次安装该模块?

Can you install packages in the OnDemand service?您可以在 OnDemand 服务中安装软件包吗?

You can try putting this at the top of the notebook:您可以尝试将其放在笔记本的顶部:

! pip install {your_package}

Then add the import statement in a new cell:然后在新单元格中添加导入语句:

import your_package

Another possibility (although it requires a few more steps) is to download the package and submit it along with your notebook.另一种可能性(尽管需要更多步骤)是下载 package 并将其与您的笔记本一起提交。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM