如何在Google Colab中获取进入安装软件包的系统路径



我正在尝试从GitHub安装我的代码。

在我的github中的文件夹中,我有一些脚本,这些脚本具有相对导入。我尝试运行脚本,但会遇到错误。

根据此问题,python软件包中的脚本

编辑 - 如果您的脚本。Py使用相对导入(并且您不想 更改它(,然后除了获得根源之外,没有办法做到这一点 进入环境的路径。您可以在脚本中执行此操作, 而不是将其设置在CMD壳或批处理文件中。但是它需要 在某个地方完成。这是您可以设置环境路径的方式 您的脚本:

import sys
sys.path.append(r'....pathtomypackage')
import package.other.anotherscript

所以现在我试图弄清楚我安装的github的路径是什么,但我似乎找不到它。它似乎已经正确安装了,但是只是不存在。

这是我的github

https://github.com/santosh-gupta/medicalqa

这些是我的脚本,它们具有相对导入

https://github.com/santosh-gupta/medicalqa/tree/master/scripts

这是我用来安装github的方法。

!pip install https://github.com/Santosh-Gupta/MedicalQA/archive/master.zip

我尝试使用

找到包裹
print(sys.path)
os.listdir('lib')
os.listdir('lib/python3.6')
os.listdir('lib/python3.6/site-packages')

获得脚本和代码具有相对导入的任何其他信息,都将不胜感激。

使用pip show <packagename>获取存储软件包的路径

最新更新