python中没有datetime模块如何通过easy_install安装?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/20849517/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-18 21:23:07  来源:igfitidea点击:

No datetime module in python how to install via easy_install?

pythondatetimeeasy-installpython-modulepython-datetime

提问by o_O

I can find the module https://pypi.python.org/pypi/DateTime

我可以找到模块https://pypi.python.org/pypi/DateTime

But I don't know the command to install via easy_install. I'm getting a no module named datetimeerror and so I need to get this installed.

但我不知道通过easy_install 安装的命令。我收到一个no module named datetime错误,所以我需要安装它。

采纳答案by BartoszKP

Module names are case sensitive. easy_install DateTimeworks for me:

模块名称区分大小写。easy_install DateTime对我有用:

enter image description here

在此处输入图片说明

回答by abarnert

The package, like the module, is named DateTime, not datetime. datetimeis a different module, which is already part of Python's standard library.

包和模块一样,被命名为DateTime,而不是datetimedatetime是一个不同的模块,它已经是 Python 标准库的一部分

When I do this, it works:

当我这样做时,它有效:

$ sudo easy_install-2.7 DateTime


Because easy_installis a big collection of PyPI-scraping hacks designed to make your life easier rather than an interface to a well-defined API, sometimesyou can get away with getting the case wrong, or even leaving bits off, and it'll figure out what you mean and install the right thing. But you should not rely on this, because sometimes you can'tget away with it.

因为easy_installPyPI 抓取 hack 的大集合旨在让您的生活更轻松,而不是定义明确的 API 的接口,所以有时您可以避免弄错案例,甚至忽略一些问题,它会弄清楚你的意思是安装正确的东西。但是您不应该依赖于此,因为有时您无法摆脱它。

Of course you really should be using pipinstead of easy_install.

当然,您确实应该使用pip而不是easy_install.

And you probably shouldn't be using this module at all. Notice that it says right at the top "Unless you need to communicate with Zope 2 APIs, you're probably better off using Python's built-in datetime module". And the fact that your error is no module named datetimeimplies pretty strongly that your code is trying to use datetime, not DateTime, so installing this won't help you.

你可能根本不应该使用这个模块。请注意,它在顶部说“除非您需要与 Zope 2 API 通信,否则最好使用 Python 的内置 datetime 模块”。事实上,您的错误是no module named datetime强烈暗示您的代码正在尝试使用datetime,而不是DateTime,因此安装它对您没有帮助。

回答by Edison Q

If you are on Mac:

如果您使用的是 Mac:

In order to install the DateTimelibrary you have to install 'pip' first (see Official instructionson How to install pip)

为了安装DateTime库,您必须先安装“pip”(请参阅有关如何安装 pip 的官方说明

Then you can install DateTime library running this command on Terminal:

然后您可以在终端上安装运行此命令的 DateTime 库:

pip install DateTime

Hope it helps.

希望能帮助到你。