【问题标题】:How to include pytz with cx_Freeze when doing it in a virtualenv?如何在 virtualenv 中包含 pytz 和 cx_Freeze?
【发布时间】:2015-06-03 23:00:24
【问题描述】:

我不得不再次问这个问题,因为a related question 在没有涉及 virtualenv 的情况下解决了这个问题。

现在我想要使用 cx_Freeze 将多个 virtualenv 打包到可执行文件中。我通常使用 virtualenv python 解释器运行我的 cx_Freeze 设置文件,但是当我尝试执行我的程序时,pytz 找不到文件,可能是因为如果你看到下面的错误,它正在 virtualenv 的原始目录中搜索它们他们被定位。我检查了时区文件在 zip 文件中的正确位置。

这是我在尝试运行捆绑程序时收到的错误消息:

cserpell@e431:~/src/build/exe.linux-x86_64-2.7$ ./validate 
/home/cserpell/src/build/exe.linux-x86_64-2.7/library.zip/distutils/__init__.py:14: UserWarning: The virtualenv distutils package at %s appears to be in the same location as the system distutils?
Traceback (most recent call last):
  File "/home/cserpell/src/virtualenvtest/local/lib/python2.7/site-packages/cx_Freeze/initscripts/Console.py", line 27, in <module>
    exec(code, m.__dict__)
  File "scripts/validate.py", line 9, in <module>
  File "/home/cserpell/src/scripts/script.py", line 15, in <module>
    from common import time_util
  File "/home/cserpell/src/common/time_util.py", line 31, in <module>
    SCL_TZ = pytz.timezone('America/Santiago')
  File "/home/cserpell/src/virtualenvtest/local/lib/python2.7/site-packages/pytz/__init__.py", line 180, in timezone
    raise UnknownTimeZoneError(zone)
pytz.exceptions.UnknownTimeZoneError: 'America/Santiago'

【问题讨论】:

    标签: python virtualenv cx-freeze pytz


    【解决方案1】:

    我自己找到了答案。唯一需要做的就是在我的 virtualenv 中安装 setuptools。作为记录,我在 virtualenv 中使用 pip 安装它很奇怪,但是当我运行 pip list 或 pip freeze 时,它​​没有显示 setuptools 作为要求,尽管它是针对 cx freeze 脚本的。

    【讨论】:

    • 我遇到了同样的问题,但 setuptools 没有帮助:/
    猜你喜欢
    • 1970-01-01
    • 2013-02-11
    相关资源
    最近更新 更多