【问题标题】:Installing reindent python安装 reindent python
【发布时间】:2012-08-26 17:51:46
【问题描述】:

我在使用 Notepad++ 的 Python 缩进方面有很多问题。为了解决,我尝试安装 Python reindent 模块,但我没有成功使用它。 如果有人成功了,请告诉我..

这是我尝试的步骤。

1.使用easy install我尝试安装包,

C:\Python27\Scripts>easy_install reindent
Searching for reindent
Reading http://pypi.python.org/simple/reindent/
Best match: Reindent 0.1.1
Downloading http://pypi.python.org/packages/source/R/Reindent/Reindent-0.1.1.tar
.gz#md5=878352c36c421a0b944607efba3b01ad
Processing Reindent-0.1.1.tar.gz
Running Reindent-0.1.1\setup.py -q bdist_egg --dist-dir c:\users\premvi~1\appdat
a\local\temp\easy_install-qdahih\Reindent-0.1.1\egg-dist-tmp-1z1zw8
zip_safe flag not set; analyzing archive contents...
Adding reindent 0.1.1 to easy-install.pth file
Installing reindent script to C:\Python27\Scripts

Installed c:\python27\lib\site-packages\reindent-0.1.1-py2.7.egg
Processing dependencies for reindent
Finished processing dependencies for reindent
  1. 当我在 python GUI 上执行导入命令时,它是成功的。

  2. 我在尝试使用时收到以下错误。

>>> import reindent
>>> reindent -d c:/python27/wxpython/ch2-updateui.py
SyntaxError: invalid syntax
>>> reindent -d c:\python2\wxpython\ch2-updateui.py
SyntaxError: invalid syntax

请告诉我如何解决它。

【问题讨论】:

  • 您可能正在混合制表符和空格。我不知道 Notepad++,但可能有一些选项可以使用“制表符”键插入 4 个空格而不是制表符。

标签: python


【解决方案1】:

您正在尝试从 Python 解释器而不是命令行运行命令。由于 reindent 是一个脚本程序,所以需要从命令行运行。

你想使用任何一个

 C:\...\> python -m reindent -d C:\Python27\wxpython\ch2-updateui.py

或者只是

 C:\...\> reindent -d C:\Python27\wxpython\ch2-updateui.py

在您的命令提示符处。

【讨论】:

    【解决方案2】:

    我对这个包一无所知,但是您使用的命令确实不符合 Python 语法。我猜你需要在终端中运行它,而不是 Python 解释器。

    【讨论】:

    • @user1050619 你已经安装好了,但是你用错了。当您导入它时,它可以工作,但 reindent -d c:/python27/wxpython/ch2-updateui.py 绝不是一个有效的 Python 命令。我的猜测是它应该从终端运行。
    【解决方案3】:

    尝试在 C:\Python27\Scripts 中下载 this as reindent.bat。那么它应该只是reindent path\to\file.py的问题

    【讨论】:

      猜你喜欢
      • 2011-10-29
      • 2012-06-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-05-13
      • 2011-05-05
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多