问题
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