简体   繁体   English

如何从本地 gitlab 导入模块 python?

[英]How can I import module python from my local gitlab?

I used github.com/operatorequals/httpimport, but I get an error: "KeyError: 'test_wr'".我使用了 github.com/operatorequals/httpimport,但出现错误:“KeyError:'test_wr'”。 File test_wr.py is located in my gitlab (myserver.locals)文件 test_wr.py 位于我的 gitlab (myserver.locals)

import httpimport

url = "http://myserver.locals/admin_user/python_prod/test_all_py/raw/master/test_dir/test_wr.py"
httpimport.INSECURE = True
with httpimport.remote_repo(["test_wr"], url):
    import test_wr
test_wr.init_def('Hi')

This code is from test_wr.py:此代码来自 test_wr.py:

def init_def(*args):
    return args[0]

/admin_user/ - Group /admin_user/ - 组

/python_prod/ - Group (or subgroup) /python_prod/ - 组(或子组)

/test_all_py/ - Project /test_all_py/ - 项目

/test_dir/ - the directory where the script is located (also is located init .py) /test_dir/ - 脚本所在的目录(也位于init .py)

Please help me in solve problem!请帮我解决问题!

I solved it: Raw url must be: "http://myserver.locals/admin_user/python_prod/test_all_py/raw/8e904cebf45e7025f68927d8aacd9cb669859002/test_dir"我解决了它:原始 url 必须是: "http://myserver.locals/admin_user/python_prod/test_all_py/raw/8e904cebf45e7025f68927d8aacd9cb669859002/test_dir"

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

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