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

How to get system path to installed packages in Google Colab?

我正在尝试让我的代码可以从 Github 安装。

在我的 github 的一个文件夹中,我有一些具有相关导入的脚本。我尝试了 运行 脚本,但出现错误。

根据这个 SO 问题 Run script within python package

EDIT - If your script.py uses relative imports (and you don't want to change that), then there is no way to do it except getting that root path into the environment. You can do this in your script if you want, instead of setting it in the cmd shell or batch file. But it needs to get done somewhere. Here's how you can set the environment path in your script:

import sys
sys.path.append(r'..\..\path\to\my\package')
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')

任何其他有关获取具有相关导入的脚本和代码以在 python 包中工作的信息将不胜感激。

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