如何强制 Sphinx 使用 Python 3.x 解释器 [英] How to force Sphinx to use Python 3.x interpreter

查看:40
本文介绍了如何强制 Sphinx 使用 Python 3.x 解释器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试为使用 Python 3.x 编写的项目创建文档.Sphinx 是我想要使用的工具,并且根据官方网站,其最新版本 1.1.2 兼容 Python 3.1+.我的操作系统是 Archlinux,一个使用 Python 3.2+ 作为默认 Python 包的 Linux 发行版.

I try to create documentation for a project written with Python 3.x. Sphinx is the tool I want to use and, according to the official site, its last version 1.1.2 is compatible with Python 3.1+. My OS is Archlinux, a Linux distribution which uses Python 3.2+ as the default Python package.

安装和配置很简单(easy_install -U Sphinx 然后是 sphinx-quickinstall),我从来没有被要求在 2.x 或 3.x 之间进行选择Python解释器.但是当我要求 Sphinx 创建我项目的文档时,我的代码被分析为好像我是为 Python 2.x 编写的一样.

The installation and configuration is straight forward (easy_install -U Sphinx then sphinx-quickinstall) and I was never asked to choose between the 2.x or 3.x Python interpreter. But when I ask Sphinx to create the documentation of my project, my code is analyzed as if I wrote it for Python 2.x.

Sphinx 准备好迎接 Python 3.x 了吗?我做错了吗?

Is Sphinx ready for Python 3.x? Did I make a mistake?

推荐答案

昨晚遇到您的问题时,我遇到了完全相同的问题.—我也在 Arch 上.

I had this exact same problem last night, when I came across your question. — I am also on Arch.

我想问题可能有很多不同的地方,但对我来说,解决方案是我安装了 Python 2 版本的 python-distribute 包,因此安装了 easy_install-2.7 不是 easy_install-3.2.

I guess the problem could be a number of different things, but the solution for me was that I had the Python 2 version of the python-distribute package installed and therefore had easy_install-2.7 not easy_install-3.2.

我相信在我的情况下,错误版本的 python-distribute 是由于我之前尝试从 pacman(安装 1.0.8 版)安装 Sphinx 而安装的,因此卸载 Sphinx 以及所有随后不需要的依赖项pacman -Rsu python-sphinx 然后安装 python-distribute 为我找到了正确版本的 easy_install,然后使用 easy_install<重新安装 Sphinx/code> 并且 Sphinx 安装按预期工作.

I believe in my case the wrong version of python-distribute was installed by my attempt to previously install Sphinx from pacman (which installs version 1.0.8), so uninstalling Sphinx and all subsequently unneeded dependencies pacman -Rsu python-sphinx and then installing python-distribute got me the right version of easy_install, then reinstalling Sphinx with easy_install and the Sphinx installation works as expected.

如果你有其他依赖于 python-distribute 的东西,那么这个过程可能会有点不同.但是首先尝试删除 python-distribute 并从那里开始工作.

If you have other things that depend on python-distribute then the process may be a little different. But start by just trying to remove python-distribute and work from there.

废弃最后一部分.早上太早了,我没有想好!python2-distributepython-distribute 是独立的包,我相信它们可以共存.所以,如果这是你的问题,你需要做的就是检查你有 python-distribute(不是2"),如果没有安装它,然后确保你使用 easy_install-3.2 安装 Sphinx.

Scrap that last part. It's too early in the morning and I wasn't thinking straight! python2-distribute and python-distribute are seperate packages which I believe can co-exist. So, if this is your problem all you need to do is check you have python-distribute (not "2"), if not install it, and then ensure you use easy_install-3.2 to install Sphinx.

希望对你有帮助.

这篇关于如何强制 Sphinx 使用 Python 3.x 解释器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆