remote: ImportError: No module named gitlab

本小妞迷上赌 提交于 2019-12-22 09:47:34

问题


I wrote gitlab hook with python. And added to post-receive hooks in gitlab server. When i push to remote origin server from my laptop, i get following error. But it works when i run script manually in gitlab server. How can i solve problem?

 Counting objects: 3, done.
 Writing objects: 100% (3/3), 240 bytes | 0 bytes/s, done.
 Total 3 (delta 0), reused 0 (delta 0)
 remote: Traceback (most recent call last):
 remote:   File "push.py", line 4, in <module>
 remote:     import gitlab
 remote: ImportError: No module named gitlab

回答1:


gitlab using own python2.7 binary in /opt/gitlab/embedded/bin/ path. i renamed /opt/gitlab/embedded/bin/python2.7 binary and create symbolic link with /usr/bin/python2.7

After that you must change owner of the python file with git user.

Above solution cause same problem if gitlab use own python binary. Because of that you can run script like this in post-receive hook

/usr/bin/python2.7 some_script.py



来源:https://stackoverflow.com/questions/30544625/remote-importerror-no-module-named-gitlab

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!