在 Anaconda 中找不到测试模块 Python

Can't find the test module in Anaconda Python

我在我的 Anaconda 版本 Python 中找不到 test 模块。谁能帮我解决这个问题。该模块由我尝试使用的 dpkt 库使用。

Python 2.7.8 |Anaconda 2.1.0 (x86_64)| (default, Aug 21 2014, 15:21:46)
[GCC 4.2.1 (Apple Inc. build 5577)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
Anaconda is brought to you by Continuum Analytics.
Please check out: http://continuum.io/thanks and https://binstar.org
>>> import test
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named test

快速修复:您可以从 cpython github repository 中检出 pystone.py 的副本并将其复制到 PYTHONPATH 中的 test 目录。或者您可以将其复制到 python 项目根目录中的 test 目录(丑陋的方式)。

也许 Anaconda Python 没有附带 test 模块的副本。这是 Python 2.7 的标准部分。其他时候,用户不小心用其他东西覆盖了他们的 Python 标准库的 test 模块。您可以尝试使用 OS X 附带的 Python 版本。如果同样失败,则尝试查看正在加载哪个 test 模块,然后从那里开始。

import test
print test

Alpine Linux 运送 python2-tests package.

如果您没有 Alpine lxc 容器,fetch 最快的方法是从 main repo here(或 apk fetch python2-testslxc ).

.apk 可以用压缩包解压到 .tar.gz 然后再次解压。