Question

Hi I'm trying to hook into the mercurial pretxncommit python file.
Most of my code works fine but I get this error:

error: pretxncommit.pcrcheck hook raised an exception: No module named requests transaction abort! rollback completed abort: No module named requests!

I'm trying to use requests.get. import requests works fine in another stand alone python file I made but it seems like hooking it into mercurial is causing a problem where it can't import this module.
Is that possible?

Was it helpful?

Solution

So I ended up having to add all of these lol. You have to add the path to your external packages onto the path that Mercurial is using.(http://tortoisehg.bitbucket.io/manual/2.9/faq.html) And yes it looks like they were all necessary to get the requests module working, I kept getting different import errors without them.

Here's what I added:

import sys
sys.path.append(r'C:\\Python27\\Lib\\site-packages\\')
sys.path.append(r'C:\\Python27\\Lib\\')
sys.path.append(r'C:\\Python27\\Lib\\site-packages\\requests-1.1.0-py2.7.egg\\')
sys.path.append(r'C:\\Python27\\Lib\\site-packages\\simplejson-3.1.0-py2.7.egg\\simplejson')
sys.path.append(r'C:\\Python27\\Lib\\site-packages\\simplejson-3.1.0-py2.7.egg\\')
sys.path.append(r'C:\\Python27\\Lib\\site-packages\\simplejson-3.1.0-py2.7.egg\\simplejson\\tests\\')
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top