Python cannot find dateutil.relativedelta

前端 未结 4 986
抹茶落季
抹茶落季 2021-02-05 01:57

I am trying to run a program using paster serve, but I keep getting the error:

ImportError: No module named dateutil.relativedelta

4条回答
  •  感情败类
    2021-02-05 02:33

    (The previous comment about installing python-dateutil helped me, so perhaps my comment helps someone else).

    For those on Mac OS (v10.6 (Snow Leopard); I am not sure about other versions), the dateutils package is located by default at:

    /System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python/dateutil
    

    whereas pip install writes the package out to:

    /Library/Python/2.6/site-packages
    

    and does not update the /Library/Python/2.6/site-packages/easy-install.pth file. As a result, when you import dateutil, you will still point to the old location, you can verify this by "import dateutil; dateutil.__file__".

    So what I did (probably better methods are available) was to rename the old directory (/System/Library/.../dateutil) to dateutil.obsolete and restarted Python, then ran the same set of commands again. This doesn't do anything to the path file or sys.path, but skips the old dateutils package so you can get to the new one.

提交回复
热议问题