diff --git a/python/tvm/contrib/util.py b/python/tvm/contrib/util.py
index 338567d6f61945bb0de7412f05d31805f18adc9c..e2b4011c4c0a89d110b61bf07ef27ace2a7c4f44 100644
--- a/python/tvm/contrib/util.py
+++ b/python/tvm/contrib/util.py
@@ -2,8 +2,12 @@
 from __future__ import absolute_import as _abs
 import os
 import tempfile
-import fcntl
 import shutil
+try:
+    import fcntl
+except ImportError:
+    fcntl = None
+
 
 class TempDirectory(object):
     """Helper object to manage temp directory during testing.
@@ -70,13 +74,15 @@ class FileLock(object):
     """
     def __init__(self, path):
         self.lock_file = open(path, "w")
-        fcntl.lockf(self.lock_file, fcntl.LOCK_EX)
+        if fcntl:
+            fcntl.lockf(self.lock_file, fcntl.LOCK_EX)
 
 
     def release(self):
         """Release the lock"""
         if self.lock_file:
-            fcntl.lockf(self.lock_file, fcntl.LOCK_UN)
+            if fcntl:
+                fcntl.lockf(self.lock_file, fcntl.LOCK_UN)
             self.lock_file.close()
             self.lock_file = None