简体   繁体   中英

How can I import module python from my local gitlab?

I used github.com/operatorequals/httpimport, but I get an error: "KeyError: 'test_wr'". File test_wr.py is located in my 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:

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

/admin_user/ - Group

/python_prod/ - Group (or subgroup)

/test_all_py/ - Project

/test_dir/ - the directory where the script is located (also is located 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"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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