未在 IDLE 中运行时,Python 脚本会导致 git publickey 错误

标签 python windows git github python-idle

在 windows 7 64bit 上安装了 Python 2.7,我无法选择使用哪个版本。

我已经使用 IDLE 编写脚本,当我按 F5 运行脚本时,一切都按预期进行。

但是,如果我在资源管理器中双击 Python 文件或使用 Py2Exe 将其变成可执行文件,脚本就会失败。

这是搞砸的部分:

print subprocess.check_output(["git", "pull", "origin", "master"], shell=False)

我不断收到 git 错误:

Permission denied (publickey). 
Fatal: the remote end hung up unexpectedly.

正如我所说,如果我在 IDLE 中打开脚本并从那里运行,它会很有用。我比较了两个环境中 os.environ 的输出和以下输出:

print subprocess.check_output(["ENV"], shell=False)

我看不出与特定的 git 和一般的路径有关的差异。我很难过!

附言。如果您安装了 git repo 和 python 并且有时间帮助我,请将以下代码放入您的 git repo 中的文件中:

import sys, subprocess
try:
    print "pulling from github"
    print subprocess.check_output(["git", "pull", "origin", "master"], shell=False)
except:
    print "Failed"
    print sys.exc_info()[0]
raw_input("Any key to exit.")
sys.exit(0)

右键单击该文件并选择“使用 IDLE 编辑”并按 F5。然后尝试直接双击 .py 文件......你们会发生什么?

最佳答案

尝试在cmd下运行python脚本, 确保 cmd 以管理员权限运行。 如果可行,请尝试使用鼠标右键单击从资源管理器运行它->以管理员身份运行, 或在“兼容性”选项卡的 python.exe 属性中,标记“以管理员身份运行此程序”复选框。

关于未在 IDLE 中运行时,Python 脚本会导致 git publickey 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8296973/

相关文章:

git - checkout 和 cherry-pick 有什么区别?

git: 使用 vim 时以 # 开始注释

python - Scrapy 忽略 allowed_domains?

python - 如何让多处理 python 应用程序干净地退出

c - 如何使用 Windows MessageBox() C 函数?

python-3.x - 安装Twisted:错误:需要Microsoft Visual C++ 14.0

git - 为什么 git 接受以哈希符号开头的提交消息

python - Python : generator didn't yield error 中的自定义 'with open()' 语句

python - 查找给定日期之后的第一个星期一的日期

c# - 在何处放置 Windows 窗体项目的中央错误处理程序