7

I try to execute marathon-lb.py and it throws the next error:

Traceback (most recent call last):
  File "./marathon_lb.py", line 46, in <module>
    import dateutil.parser
ImportError: No module named 'dateutil'

I just install python with apt and with pip. I have run:

sudo apt-get install python-pip
pip install python-dateutil

I compile the script with: python -m py_compile script.py

python application:

from operator import attrgetter
from shutil import move
from tempfile import mkstemp
from wsgiref.simple_server import make_server
from six.moves.urllib import parse
from itertools import cycle
from common import *
from config import *
from lrucache import *
from utils import *

import argparse
import json
import logging
import os
import os.path
import stat
import re
import requests
import shlex
import subprocess
import sys
import time
import dateutil.parser
Asier Gomez
  • 6,034
  • 18
  • 52
  • 105

2 Answers2

13

Install python-dateutil

pip install python-dateutil
Tanu
  • 1,503
  • 12
  • 21
  • does this statement runs on python shell `import dateutil.parser` ? – Tanu May 25 '16 at 11:08
  • Yes it runs on python shell – Asier Gomez May 26 '16 at 07:25
  • So is it still giving error when you try to compile script? – Tanu May 26 '16 at 07:27
  • 1
    There are probably multiple versions of `python-dateutil` installed. Try to issue `pip uninstall python-dateutil` several times until the prompt says there is no `python-dateutil` installed. Then, you can issue `pip install python-dateutil` again. That solves my problem. – xxks-kkk Nov 05 '17 at 06:32
0

Step 1. First thing is upgrade pip for corresponding python version (3 or 2) you have.

pip3 install --upgrade pip

or

pip2 install --upgrade pip

Step2.

Some times directly running command wont work since

There are probably multiple versions of python-dateutil installed.

  1. Try to run pip uninstall python-dateutil

will give below message if python-dateutil is already un installed.

Cannot uninstall requirement python-dateutil, not installed

  1. Then, you can run pip install python-dateutil again.

NOTE : Directly running step2 wont work for users whose python and pip versions are not compatible.

Ram Ghadiyaram
  • 28,239
  • 13
  • 95
  • 121