How to install python-dateutil on Windows?
Asked Answered
P

11

51

I'm trying to convert some date/times to UTC, which I thought would be dead simple in Python - batteries included, right? Well, it would be simple except that Python (2.6) doesn't include any tzinfo classes. No problem, a quick search turns up python-dateutil which should do exactly what I need.

The problem is that I need to install it on Windows. I was able to upack the .tar.gz2 distribution using 7-zip, but now I'm left with a collection of files and no guidance on how to proceed. When I try to run setup.py I get the error "No module named setuptools".

Preconceive answered 18/5, 2009 at 18:38 Comment(4)
pip install python-dateutilToliver
@avastreg, i get the error: SyntaxError: invalid syntax when I try that commandSeptet
@starbox, that should be in the terminal (or command prompt), not in the Python console.Bezant
Find ans hereFigured
B
69

If dateutil is missing install it via:

pip install python-dateutil

Or on Ubuntu:

sudo apt-get install python-dateutil
Barrett answered 25/8, 2011 at 8:5 Comment(2)
I guess you meant pip install python-dateutil?Coppice
Finally had a chance to try this with Python 3.5. On Windows the full command I needed was: python -m pip install python-dateutil.Preconceive
P
18

Why didn't someone tell me I was being a total noob? All I had to do was copy the dateutil directory to someplace in my Python path, and it was good to go.

Preconceive answered 18/5, 2009 at 21:15 Comment(5)
@eyquem, Python defines a tzinfo class without providing any implementations; not even a UTC timezone, which would be trivial.Preconceive
The second anwser (install via pip) is better answer than this one. It plays better with virtualenv and it will allow you to update the version in the future if you need it.Stony
@Davisein, pip doesn't come with Python for Windows either, although I understand that's changing. And when I asked the question, I believe pip was still quite new.Preconceive
@MarkRansom Sure! I noticed the date of the answer but I thought it will help people to recommend a different option nowadays. But I am sure when it was answered it was the best option.Stony
I can confirm Python 2.7.10 (May 2015) on Windows does come with pip, so I would recommend @Jhossep's answer as the simplest and cleanestImpatience
R
6

Looks like the setup.py uses easy_install (i.e. setuptools). Just install the setuptools package and you will be all set.

To install setuptools in Python 2.6, see the answer to this question.

Reynoso answered 18/5, 2009 at 18:49 Comment(3)
I've answered my own question - no, setuptools won't install unless it finds the specific version of Python it has been built for. I'll need some other method.Preconceive
You should be able to... see the link I posted in the answer.Reynoso
Thanks for everything. I gave you an upvote, even though I didn't use setuptools in the end.Preconceive
C
5

Install from the "Unofficial Windows Binaries for Python Extension Packages"

http://www.lfd.uci.edu/~gohlke/pythonlibs/#python-dateutil

Pretty much has every package you would need.

Claque answered 26/9, 2013 at 14:2 Comment(3)
Thanks. I'm a little leery of running exe's from some random site on the internet though.Preconceive
It's not a random site, it is UC, Irvine (and the page is recommended by the scikit team scikit-learn.org/stable/install.html#windows-installer)Claque
The link is broken as for 1/7/2014Mockheroic
R
5

It is a little tricky for people who is not used to command prompt. All you have to do is open the directory where python is installed (C:\Python27 by default) and open the command prompt there (shift + right click and select open command window here) and then type :

python -m pip install python-dateutil

Hope that helps.

Rivard answered 9/12, 2015 at 3:12 Comment(0)
T
3

Using setup from distutils.core instead of setuptools in setup.py worked for me, too:

#from setuptools import setup
from distutils.core import setup
Tishtisha answered 26/4, 2010 at 21:38 Comment(0)
S
1

If you are offline and have untared the package, you can use command prompt.

Navigate to the untared folder and run:

python setup.py install
Soprano answered 24/8, 2015 at 9:24 Comment(0)
R
0

Just run command prompt as administrator and type this in.

easy_install python-dateutil
Rondi answered 9/1, 2014 at 22:58 Comment(0)
R
0

You could also change your PYTHONPATH:

$ python -c 'import dateutil'
   Traceback (most recent call last):
     File "<string>", line 1, in <module>
   ImportError: No module named dateutil
$
$ PYTHONPATH="/usr/lib/python2.6/site-packages/python_dateutil-1.5-py2.6.egg":"${PYTHONPATH}"
$ export PYTHONPATH
$ python -c 'import dateutil'
$

Where /usr/lib/python2.6/site-packages/python_dateutil-1.5-py2.6.egg is the place dateutil was installed in my box (centos using sudo yum install python-dateutil15)

Respectively answered 29/10, 2014 at 9:32 Comment(0)
T
0

First confirm that you have in C:/python##/Lib/Site-packages/ a folder dateutil, perhaps you download it, you should already have pip,matplotlib, six##,,confirm you have installed dateutil by--- go to the cmd, cd /python, you should have a folder /Scripts. cd to Scripts, then type --pip install python-dateutil -- ----This applies to windows 7 Ultimate 32bit, Python 3.4------

Twinflower answered 26/4, 2015 at 13:46 Comment(0)
A
0

I followed several suggestions in this list without success. Finally got it installed on Windows using this method: I extracted the zip file and placed the folders under my python27 folder. In a DOS window, I navigated to the installed root folder from extracting the zip file (python-dateutil-2.6.0), then issued this command:

.\python setup.py install

Whammo-bammo it all worked.

Ardell answered 6/12, 2016 at 19:10 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.