如何在 Windows 上安装 python-dateutil?
我正在尝试将一些日期/时间转换为 UTC,我认为这在 Python 中非常简单 - 包括电池,对吗? 嗯,这很简单,只是 Python (2.6) 不包含任何 tzinfo 类。 没问题,快速搜索会发现 python-dateutil ,它应该完全满足我的需要。
问题是我需要在 Windows 上安装它。 我能够使用 7-zip 打包 .tar.gz2 发行版,但现在我只剩下一组文件,并且没有关于如何继续的指导。 当我尝试运行 setup.py 时,出现错误“没有名为 setuptools 的模块”。
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".
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(11)
如果 dateutil 丢失,请通过以下方式安装:
或在 Ubuntu 上:
If dateutil is missing install it via:
Or on Ubuntu:
为什么没有人告诉我我是个十足的菜鸟? 我所要做的就是将
dateutil
目录复制到我的 Python 路径中的某个位置,然后就可以了。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.看起来 setup.py 使用 easy_install (即
setuptools
)。 只需安装 setuptools 包就可以了。要在 Python 2.6 中安装 setuptools,请参阅此问题的答案< /a>.
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.
从“Python 扩展包的非官方 Windows 二进制文件”
http://www .lfd.uci.edu/~gohlke/pythonlibs/#python-dateutil
几乎拥有您需要的每个包。
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.
只需以管理员身份运行命令提示符并输入以下内容即可。
Just run command prompt as administrator and type this in.
对于不习惯命令提示符的人来说,这有点棘手。 你拥有的一切
要做的就是打开 python 安装目录(默认为 C:\Python27)并打开命令提示符(Shift + 右键单击并选择在此处打开命令窗口),然后输入:
python -m pip install python- dateutil
希望有帮助。
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.
使用
distutils.core
中的setup
而不是 setup.py 中的setuptools
也对我有用:Using
setup
fromdistutils.core
instead ofsetuptools
in setup.py worked for me, too:如果您处于离线状态并且已解压软件包,则可以使用命令提示符。
导航到解压的文件夹并运行:
If you are offline and have untared the package, you can use command prompt.
Navigate to the untared folder and run:
您还可以更改 PYTHONPATH:
其中
/usr/lib/python2.6/site-packages/python_dateutil-1.5-py2.6.egg
是安装 dateutil 的位置在我的盒子里(centos 使用sudo yum install python-dateutil15
)You could also change your PYTHONPATH:
Where
/usr/lib/python2.6/site-packages/python_dateutil-1.5-py2.6.egg
is the place dateutil was installed in my box (centos usingsudo yum install python-dateutil15
)首先确认你在 C:/python##/Lib/Site-packages/ 中有一个文件夹 dateutil,也许你下载了它,你应该已经有 pip,matplotlib, Six##,,确认你已经安装了 dateutil ---转到cmd,cd /python,你应该有一个文件夹/Scripts。 cd 到 Scripts,然后输入 --pip install python-dateutil --
----这适用于windows 7 Ultimate 32位,Python 3.4--------
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------
我遵循了此列表中的几条建议,但没有成功。 最后使用以下方法将其安装在 Windows 上:我提取了 zip 文件并将文件夹放在我的
python27
文件夹下。 在 DOS 窗口中,我通过提取 zip 文件 (python-dateutil-2.6.0
) 导航到已安装的根文件夹,然后发出以下命令:Whammo-bammo 一切正常。
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:Whammo-bammo it all worked.