我在跑步:
Ubuntu 13.04
Python 2.7.4
我正在尝试这个关于制作蟒蛇蛋的非常简单的教程,但是当我实际尝试运行命令来制作蛋时我遇到了困难.
<me>@<compname>:~/Desktop/SANDBOX/somedir$ python setup.py bdist_egg
usage: setup.py [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]
or: setup.py --help [cmd1 cmd2 ...]
or: setup.py --help-commands
or: setup.py cmd --help
error: invalid command 'bdist_egg'
Run Code Online (Sandbox Code Playgroud)
到目前为止我所知道的:当我输入命令时,
$ python setup.py --help-commands
Run Code Online (Sandbox Code Playgroud)
我找回所有正常命令,但不是"额外命令".我尝试使用谷歌搜索和搜索Stack Overflow但尚未产生任何有用的结果.我知道我很可能错过了一个依赖,但我相信我安装了所有必需的部分来使这项工作.
任何见解都非常感谢.谢谢.
我目前在Windows 7 64位机器上使用python 2.7.3(也在Linux 32位,Ubuntu 12.04中开发),并且在使用python与命令提示符/终端成功通信方面遇到了奇怪的困难.我的代码看起来像这样:
import subprocess, logging, platform, ctypes
class someClass (object):
def runTerminalCommand:
try:
terminalOrCmdLineCommand = self.toString()
process = subprocess.Popen(terminalOrCmdLineCommand, shell=True,stdout=subprocess.PIPE,stderr=subprocess.PIPE)
output = process.stdout.readlines()
if len(output) < 1:
logging.exception("{} error : {}".format(self.cmd,process.stderr.readlines()))
raise ConfigError("cmd issue : {}".format(self.cmd))
return output
except ValueError as err:
raise err
except Exception as e:
logging.exception("Unexpected error : " + e.message)
raise ConfigError("unexpected error")
Run Code Online (Sandbox Code Playgroud)
现在,我知道如果我手动输入self.toString()返回值将正确处理,所以我将这限制为我如何通过子进程将其发送到命令行的问题.我已经阅读了文档,发现如果遇到错误,subprocess.check_call()不会返回任何内容,所以我正在使用.Popen()
我得到的例外是,
[date & time] ERROR: Unexpected error :
Traceback (most recent call last):
File "C:\[...]"
raise ConfigError("cmd issue …
Run Code Online (Sandbox Code Playgroud) 一些环境基础Python版本:3.4.2操作系统:Windows 8.1
搜索到目前为止,我怀疑这个问题与我手头的问题有关,但我不确定我是如何复制足够的相同条件 - 可能是我缺乏深入的python知识.
用于重现问题的简化代码:
基类
from PySide.QtGui import *
class Interface(QWidget):
'''
Wrapper base class for GUI input QWidgets:
- buttons
- text fields
- checkboxes
- line edit
- dropdown menu (combo box)
'''
def __init__(self, parent, name, title_txt=None, qt_obj=None,
update_log_method=None):
print('Interface base class constructor has been called.') #DEBUG
self._parent = parent
self.title = None
self.name = name #also text that appears on component
self.qt_obj = qt_obj
self.inheritted_log_method = update_log_method
# don't want …
Run Code Online (Sandbox Code Playgroud)