如何在 Windows 上安装 python-dateutil?

发布于 2024-07-21 01:26:49 字数 353 浏览 10 评论 0原文

我正在尝试将一些日期/时间转换为 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(11

别挽留 2024-07-28 01:26:49

如果 dateutil 丢失,请通过以下方式安装:

pip install python-dateutil

或在 Ubuntu 上:

sudo apt-get install python-dateutil

If dateutil is missing install it via:

pip install python-dateutil

Or on Ubuntu:

sudo apt-get install python-dateutil
紫罗兰の梦幻 2024-07-28 01:26:49

为什么没有人告诉我我是个十足的菜鸟? 我所要做的就是将 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.

情绪失控 2024-07-28 01:26:49

看起来 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.

等往事风中吹 2024-07-28 01:26:49

从“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.

热情消退 2024-07-28 01:26:49

只需以管理员身份运行命令提示符并输入以下内容即可。

easy_install python-dateutil

Just run command prompt as administrator and type this in.

easy_install python-dateutil
我为君王 2024-07-28 01:26:49

对于不习惯命令提示符的人来说,这有点棘手。 你拥有的一切
要做的就是打开 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.

半透明的墙 2024-07-28 01:26:49

使用 distutils.core 中的 setup 而不是 setup.py 中的 setuptools 也对我有用:

#from setuptools import setup
from distutils.core import setup

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

#from setuptools import setup
from distutils.core import setup
浮世清欢 2024-07-28 01:26:49

如果您处于离线状态并且已解压软件包,则可以使用命令提示符。

导航到解压的文件夹并运行:

python setup.py install

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
爱你不解释 2024-07-28 01:26:49

您还可以更改 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'
$

其中 /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:

$ 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)

镜花水月 2024-07-28 01:26:49

首先确认你在 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------

盗琴音 2024-07-28 01:26:49

我遵循了此列表中的几条建议,但没有成功。 最后使用以下方法将其安装在 Windows 上:我提取了 zip 文件并将文件夹放在我的 python27 文件夹下。 在 DOS 窗口中,我通过提取 zip 文件 (python-dateutil-2.6.0) 导航到已安装的根文件夹,然后发出以下命令:

.\python setup.py install

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:

.\python setup.py install

Whammo-bammo it all worked.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文