Python 找不到满足 pytz 要求的版本

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/18230956/
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-19 10:15:32  来源:igfitidea点击:

Could not find a version that satisfies the requirement pytz

pythonpipvirtualenvpytz

提问by Houman

I have a problem installing pytzin virtualenv.

我在 virtualenv 中安装pytz时遇到问题。

Downloading/unpacking pytz
Could not find a version that satisfies the requirement pytz (from versions: 2009r, 2008b, 2009f, 2008c, 2007g, 2011g, 2005m, 2011e, 2007f, 2011k, 2007k, 2006j, 2008h, 2008i, 2011e, 2008a, 2009e, 2006g, 2011j, 2010l, 2005m, 2008i, 2005k, 2008g, 2007c, 2007i, 2009l, 2009r, 2006j, 2011k, 2007d, 2006p, 2009i, 2009u, 2007i, 2009f, 2010g, 2008h, 2009a, 2007g, 2011e, 2006p, 2012b, 2010k, 2005r, 2007f, 2009l, 2009p, 2008c, 2009j, 2008g, 2010g, 2010h, 2011h, 2010k, 2007c, 2007d, 2011d, 2009l, 2011c, 2008a, 2005m, 2007k, 2009n, 2011d, 2010o, 2013b, 2012h, 2010e, 2012c, 2012d, 2012f, 2011n, 2011b, 2011j, 2008c, 2012j, 2007k, 2009f, 2009d, 2010e, 2010b, 2013b, 2011d, 2009p, 2008h, 2005r, 2009i, 2009n, 2009a, 2010k, 2008g, 2006g, 2008b, 2012c, 2009i, 2007g, 2012c, 2010h, 2011n, 2012g, 2007d, 2008a, 2009u, 2012g, 2010o, 2006p, 2010b, 2009u, 2012d, 2011k, 2012f, 2009a, 2007f, 2011h, 2010l, 2009j, 2011g, 2009g, 2009g, 2005r, 2011c, 2012g, 2009g, 2012d, 2009j, 2010o, 2007c, 2010g, 2006g, 2009d, 2010h, 2005k, 2006j, 2010b, 2009n, 2011g, 2011c, 2012b, 2009e, 2009d, 2011j, 2007i, 2012j, 2010l, 2009r, 2012h, 2010e, 2009p, 2008i, 2012f, 2009e, 2012b, 2011h, 2005k, 2008b, 2013b, 2011n, 2012j, 2004b)
Cleaning up...
No distributions matching the version for pytz

下载/解压pytz
找不到满足 pytz 要求的版本(来自版本:2009r, 2008b, 2009f, 2008c, 2007g, 2011g, 2005m, 2011e, 2007f, 2011k, 2006e, 09e, 2006e, 09e, 09e, 2008c, 09e, 2008c, 09e, 09 2011j,2010升,2005米,2008i中,2005k,2008克,2007年c,2007i,2009升,2009r,2006j,2011k,2007年d,2006P,2009i,2009u,2007i,2009f,2010克,地址为2008h,2009a的,2007克,2011E,2006P,2012B, 2010K,2005r,2007F,2009升,2009p,2008年c,2009j,2008克,2010克,2010H,2011h,2010K,2007年c,2007年d,2011D,2009升,2011C,2008A,2005米,2007k,2009n,2011D,2010o,2013b,2012H, 2010E,2012c,2012d,2012F,2011n,2011B,2011j,2008年c,2012j,2007k,2009f,2009d,2010E,2010年b,2013b,2011D,2009p,地址为2008h,2005r,2009i,2009n,2009a的,2010K,2008克,2006克, 2008b, 2012c, 2009i, 2007g, 2012c, 2010h, 2011n, 2012g, 2007d, 2008a, 2009u, 2012g, 2010o, 20010b, 20010d, 20010p2011k,2012F,2009a的,2007F,2011h,2010升,2009j,2011克,2009克,2009克,2005r,2011C,2012克,2009克,2012d,2009j,2010o,2007年c,2010克,2006克,2009d,2010H,2005k,2006j,2010年b, 2009n,2011克,2011C,2012B,2009E,2009d,2011j,2007i,2012j,2010升,2009r,2012H,2010E,2009p,2008i中,2012F,2009E,2012B,2011h,2005k,2008B,2013b,2011n,2012j,2004b中)
正在清理...
没有与 pytz 版本匹配的发行版

It seems like it's a problem with the latest version of pip.

好像是最新版本的pip有问题。

Is there any workaround?

有什么解决方法吗?

采纳答案by Facebook Staff are Complicit

This error occurs when installing pytzusing pip v1.4 or newer, due to this change in behaviour:

pytz使用 pip v1.4 或更高版本进行安装时会发生此错误,原因是行为发生了这种变化:

Pre-release Versions

Starting with v1.4, pip will only install stable versions as specified by PEP426by default. If a version cannot be parsed as a compliant PEP426version then it is assumed to be a pre-release.

If a Requirement specifier includes a pre-release or development version (e.g. >=0.0.dev0) then pip will allow pre-release and development versions for that requirement. This does not include the !=flag.

The pip installcommand also supports a --preflag that will enable installing pre-releases and development releases.

预发布版本

从 v1.4 开始,pip 将默认只安装PEP426指定的稳定版本。如果某个版本无法解析为符合PEP426 的版本,则假定它是预发布版本。

如果需求说明符包含预发布或开发版本(例如>=0.0.dev0),则 pip 将允许该需求的预发布和开发版本。这不包括!=标志。

pip install命令还支持一个--pre允许安装预发布和开发版本的标志。

The version identifiers for the pytzpackage have a format like 2013b. PEP426uses the version identifiers described in PEP440, which specifies that:

pytz包的版本标识符的格式类似于2013b. PEP426使用中所描述的版本标识符PEP440,它规定:

Public version identifiers MUST comply with the following scheme:

N[.N]+[{a|b|c|rc}N][.postN][.devN]

公共版本标识符必须符合以下方案:

N[.N]+[{a|b|c|rc}N][.postN][.devN]

Because the pytzversions like 2013bdo not match this format, version 1.4+ of pip is treating allversions of pytzas pre-release versions, and is not installing them by default.

因为pytz2013b这样的版本不符合这种格式,所以pip 1.4+版本将所有版本都pytz视为预发布版本,并且默认不安装它们。

If you are only installing pytz, you can use the --preflag to avoid this behaviour, but you wouldn't want to use this flag for installing your entire project's requirements: some packages might have unstable pre-release versions you don't want. In that case, use the behaviour described above: if you specify a "pre-release" version number for the package, then pip will search for "pre-release" versions of the package. So I've added this to my requirements.txt:

如果您只是安装pytz,您可以使用该--pre标志来避免这种行为,但您不希望使用该标志来安装整个项目的要求:某些软件包可能具有您不想要的不稳定的预发布版本。在这种情况下,请使用上述行为:如果您为包指定“预发布”版本号,则 pip 将搜索包的“预发布”版本。所以我已将其添加到我的requirements.txt

pytz>=2013b

When I upgrade my packages, pip will now correctly search for and install the latest version of pytz.

当我升级我的软件包时,pip 现在将正确搜索并安装最新版本的pytz.

This has been filed as issue #1204837 in the pytz bug trackerand issue #974 in the pip bug tracker.

这已在 pytz 错误跟踪器中作为问题 #1204837pip 错误跟踪器中的问题 #974提交。

Stop Press: As described in the PyTz bug report, the version numbering of pytz has now been changed to, for example, 2013.7 - so once you have upgraded to this, the problem should no longer occur.

停止按:如PyTz 错误报告中所述,现在pytz的版本编号已更改为,例如,2013.7 - 因此一旦升级到此,问题将不再出现。

回答by Mary Page

Just a student. I was learning pytz(downloaded, Run, command prompt then tried IntelliJ, Project Structure, SDKS) and it would not import even after deleting, redoing the files. Read the Launchtype bug list. I switched to pendulum. It worked with prior script that used pytz. Just an idea not a direct answer. Original script was Buchalka (teaching Python3 script in a lesson and lesson would not work with IntelliJ) with pytz. Adapted script to pendulum(Intellij,Project Structure, SDKS, +) so I could experience timezone. (no indents with this block of code) Posting since a search of Internet sites did not reveal much help to solve pytz. Pendulum offered an alternative.

只是一个学生。我正在学习pytz(下载,运行,命令提示符然后尝试IntelliJ,项目结构,SDKS)并且即使删除,重做文件也不会导入。阅读 Launchtype 错误列表。我切换到钟摆。它与使用 pytz 的先前脚本一起使用。只是一个想法,而不是直接的答案。原始脚本是带有 pytz 的 Buchalka(在课程中教授 Python3 脚本,并且课程不适用于 IntelliJ)。将脚本改编为钟摆(Intellij,项目结构,SDKS,+),以便我可以体验时区。(此代码块没有缩进)由于搜索 Internet 站点并没有发现对解决 pytz 有多大帮助而发帖。Pendulum 提供了另一种选择。

import pendulum
import datetime
country = "Europe/Paris"

tz_to_display = pendulum.timezone(country)
local_time = datetime.datetime.now(tz=tz_to_display)
print("The time in {} is {}".format(country, local_time))
print("UTC is {}".format(datetime.datetime.utcnow()))

For those with more knowledge and more complicated script here is the pendulum site. https://pendulum.eustace.io/blog/a-faster-alternative-to-pyz.htmlA library exists for pendulum on the site. It states ( SéBASTIEN EUSTACE)

对于那些有更多知识和更复杂脚本的人来说,这里是钟摆站点。https://pendulum.eustace.io/blog/a-faster-alternative-to-pyz.html网站上有一个摆锤库。它指出(SéBASTIEN EUSTACE)

This is due to the fact that Pendulum relies heavily on the presence of the fold attribute which was introduced in Python 3.6.

这是因为 Pendulum 严重依赖于 Python 3.6 中引入的 fold 属性。

The reason it works inside the Pendulum ecosystem is that it backported the fold attribute in the DateTime class.

它在 Pendulum 生态系统中工作的原因是它向后移植了 DateTime 类中的 fold 属性。