Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

remote: ImportError: No module named gitlab

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
like image 437
Gokhan MANKARA Avatar asked Sep 27 '22 18:09

Gokhan MANKARA


1 Answers

gitlab's 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

like image 102
Gokhan MANKARA Avatar answered Oct 03 '22 08:10

Gokhan MANKARA