我正在尝试使我的代码可以从Github安装
在github的一个文件夹中,我有一些具有相对导入的脚本。我尝试运行脚本,但出现了错误
根据这个问题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
我试着使用
我找到了模块使用的路径
!pip show MedicalQA
然后,我使用
sys.path.append(r'/usr/local/lib/python3.6/dist-packages/MedicalQA')
但是,当我导入脚本时,仍然会出现错误
import Scripts.inference_question_to_topk.py
如果有任何其他信息可以让脚本和相关导入的代码在python包中工作,我们将不胜感激
目前没有回答
相关问题 更多 >
编程相关推荐