1

我正在运行默认使用 python 2.7 的 Ubuntu 12.10。我已经在 /opt/python3.3 中安装了 python 3.3(使用 ./configure --prefix=/opt/python3.3)并创建了一个符号链接 /usr/bin/python33 指向 /opt 中的可执行文件。已经有一个符号链接 /usr/bin/python3 指向 python 3.2(实际上它指向 python3.2mu:如果你可以解释一下为什么包含这个'mu' :))安装附带ubuntu 安装。我使用 python3 安装了分发工具,没有任何问题。但是当我用 python33 尝试同样的事情时,它给了我以下错误:

ankur@junk-mechanism:~$ sudo python33 distribute_setup.py
Extracting in /tmp/tmp685lyf
lzma module is not available
not a bzip2 file
gzip module is not available
bad checksum
Traceback (most recent call last):
  File "distribute_setup.py", line 550, in <module>
    sys.exit(main())
  File "distribute_setup.py", line 547, in main
    return _install(tarball, _build_install_args(options))
  File "distribute_setup.py", line 78, in _install
    tar = tarfile.open(tarball)
  File "/opt/python3.3/lib/python3.3/tarfile.py", line 1578, in open
    raise ReadError("file could not be opened successfully" + str(name) + repr(fileobj))
tarfile.ReadError: file could not be opened successfully/home/ankur/distribute-0.6.35.tar.gzNone

所以在 tarfile.py 中,类方法 Tarfile.open 调用了导入模块 gzip 的类方法 Tarfile.gzopen:

    try:
        import gzip
        gzip.GzipFile
    except (ImportError, AttributeError):
        raise CompressionError("gzip module is not available")

此处引发的错误是 ImportError,因为 gzip.py 有一个无法找到的导入 zlib。但即使是其他安装的 python(2.7 和 3.2)也不在各自的标准库 /usr/lib/pythonx.x/lib/ 中包含 zlib。那么区别是什么呢?

4

1 回答 1

1

听起来您因为缺少依赖项而没有构建所有内容。您可以尝试获取缺少的依赖项并重新构建。要获取缺少的依赖项,我只需按照 Python 3.2 的要求工作并执行以下操作:

sudo apt-get build-dep python3

然后您可以重新配置和重建 Python 3.3 以获得所有必需的模块。

另一种选择是使用死蛇 ppa:

sudo add-apt-repository ppa:fkrull/deadsnakes
sudo apt-get update
sudo apt-get install python3.3

我通常也安装 -dev 包,以便我可以安装具有 C 扩展模块的包:

sudo apt-get install python3.3-dev
于 2013-04-03T09:27:30.463 回答