I have a piece of code that currently runs without any issues on my local python (anaconda python 3.5.1) but is giving me an odd error when I run it in production (where I am under the impression the environment is very similar and the python version is the same).
Below is the relevant code snippet:
ds_date_format = "%Y%m%d"
rta_date_format = '%a %b %d %H:%M:%S %Z %Y'
d1 = datetime.datetime.strptime(date_ds, ds_date_format)
d2 = datetime.datetime.strptime(date_rta, rta_date_format).replace(hour=0, minute=0, second=0)
And the traceback for the error I am getting.
{
  "error": {
    "traceback": [
      "Traceback (most recent call last):\n",
      "  File \"/opt/conda/lib/python3.5/site-packages/tornado/web.py\", line 1445, in _execute\n    result = yield result\n",
      "  File \"/opt/conda/lib/python3.5/site-packages/tornado/gen.py\", line 1008, in run\n    value = future.result()\n",
      "  File \"/opt/conda/lib/python3.5/site-packages/tornado/concurrent.py\", line 232, in result\n    raise_exc_info(self._exc_info)\n",
      "  File \"<string>\", line 3, in raise_exc_info\n",
      "  File \"/opt/conda/lib/python3.5/site-packages/tornado/gen.py\", line 1017, in run\n    yielded = self.gen.send(value)\n",
      "  File \"<string>\", line 6, in _wrap_awaitable\n",
      "  File \"rtamatching.py\", line 171, in post\n    self.write(await self.rta_matcher.check_matches(data))\n",
      "  File \"rtamatching.py\", line 114, in check_matches\n    date_match_scores.append(date_similarity(date, user_feeds[key]['TransactionDate']))\n",
      "  File \"/opt/api/functions.py\", line 9, in date_similarity\n    d2 = datetime.datetime.strptime(date_rta, rta_date_format).replace(hour=0, minute=0, second=0)\n",
      "  File \"/opt/conda/lib/python3.5/_strptime.py\", line 500, in _strptime_datetime\n    tt, fraction = _strptime(data_string, format)\n",
      "  File \"/opt/conda/lib/python3.5/_strptime.py\", line 337, in _strptime\n    (data_string, format))\n",
      "ValueError: time data 'Wed Mar 09 21:59:50 PST 2016' does not match format '%a %b %d %H:%M:%S %Z %Y'\n"
    ],
    "code": 500,
    "message": "Internal Server Error"
  }
}
That value error seems odd to be because as far as I can tell, the format specified is correct.
