Python 无法安装时间模块
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/42522650/
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
Can't install time module
提问by jwodder
I've tried pip install time
and sudo -H pip install time
, but I keep getting the error:
我试过pip install time
and sudo -H pip install time
,但我一直收到错误:
Could not find a version that satisfies the requirement time (from versions: ) No matching distribution found for time
找不到满足要求时间的版本(来自版本:)找不到时间匹配的分布
I'm working in PyCharm, but what really doesn't make sense is that I can import time in the Python Console but not in my actual code.
我正在 PyCharm 中工作,但真正没有意义的是我可以在 Python 控制台中导入时间,但不能在我的实际代码中导入时间。
回答by jwodder
The time
moduleis part of Python's standard library. It's installed along with the rest of Python, and you don't need to (nor can you!) install it with pip
.
该time
模块是 Python 标准库的一部分。它与 Python 的其余部分一起安装,您不需要(也不能!)使用pip
.
I can import time in the Python Console
我可以在 Python 控制台中导入时间
Yes, because it's already installed.
是的,因为它已经安装了。
but not in my actual code
但不是在我的实际代码中
I don't believe you. Show us the exact error message you get when you try.
我不相信你。向我们展示您在尝试时收到的确切错误消息。
回答by snibbets
I think this is a PyCharm bug. I am using the time module with PyCharm and it complains that 'time' is an unresolved reference, even when I use
我认为这是 PyCharm 的错误。我正在使用 PyCharm 的时间模块,它抱怨“时间”是一个未解析的引用,即使我使用
import time
at the beginning of my file. However, there is no run-time error when I execute my program, even though PyCharm does not recognise time
as a valid module.
在我的文件的开头。然而,当我执行我的程序时没有运行时错误,即使 PyCharm 不能识别time
为有效模块。
回答by Manny Gonzalez
Try using time.sleep(secs)
that should work fine.
尝试使用time.sleep(secs)
它应该可以正常工作。
回答by MohanBabu
I have also got the error, while referring the time on the 'requirements.txt' and pushing app to cloud foundry.
我也遇到了错误,同时参考了“requirements.txt”上的时间并将应用程序推送到云代工厂。
So the errors is expected. So, its possible on other scenarios also. I just removed the time from the 'requirements.txt' before push my app to make it work.!
所以错误是预料之中的。因此,它也可能用于其他场景。在推送我的应用程序以使其工作之前,我刚刚从“requirements.txt”中删除了时间。!
回答by moe_
time is pre-installed because when I import time "import time" everything goes well
时间是预先安装的,因为当我导入时间“导入时间”时一切顺利
回答by reminosouci
I think I had the same problem, I think it's because one variable was called time...
我想我有同样的问题,我认为这是因为一个变量被称为时间......