title: (Errno 101) Network is unreachable when executing python script using crontab
body: <p>I want to retrieve some information form webstie using below script. It works well using command line. However, "error 101" problem is met when scheduled using crontab. I can' figure out the root cause, could you help to give some advice? Thanks!</p>
  
  <pre><code>    req = urllib2.Request(tempURL)
      req.add_header('User-Agent', ua)
      try:
          response = urllib2.urlopen(req, timeout=10)
          data = response.read()
          print data
          response.close()
          logging.info("Successfully get information about city " + str(k))
      except urllib2.URLError, e:
          logging.info("Failed to crawl url " + tempURL)
  </code></pre>
  
  <p>My python environement:</p>
  
  <p>The machine is redhat with python 2.6.6 installed.In order to use python2.7.4. I downloaded python-2.7.4.tar from web and build myself. Also add below environment variable to /etc/profile</p>
  
  <pre><code>PYHOME=$The unpacked path
  </code></pre>
  
  <p>After doing that, I got below information</p>
  
  <pre><code>[]$ python --version
   &gt;&gt;&gt; Python 2.7.4
  </code></pre>
  
  <p>Then as googled, I create a shell script to set the ENV for python script.This shell script will be used for crontab schedule</p>
  
  <pre><code>#!/bin/bash
  export PYHOME=$Python274_location
  python my.py
  </code></pre>
  
  <p>If you execute 'python my.py 'in command line directly, you can get the correct result.But if scheduled in crontab, I will always get below errors.</p>
  
  <pre><code>ERROR:root:Failed to reach server. Reason: [Errno 101] Network is unreachable
  </code></pre>
  
  <p>In my opinion, it should be related my python ENV, but has no clue till now.</p>