在 Windows 7 上安装 Python 并分发会出现“写入失败...权限被拒绝”的错误消息

发布于 2024-12-27 23:19:32 字数 3605 浏览 2 评论 0原文

我使用的是 Windows 7(我完全承认我不了解其权限模型。我正在其他选项卡中阅读相关内容。)我的用户是管理员。当我尝试运行“python allocate_setup.py”时,出现“写入失败...权限被拒绝”错误,然后出现“错误:无法在安装目录中创建或删除文件”。

我刚刚从 python.org 安装了 Python 3.2.2 MSI 安装程序。

即使我在 64 位 Windows 上,我也会安装 32 位 Python,因为我会有一些需要它的依赖项(pyglet,一个 OpenGL 库。)

我下载 allocate_setup.py 并从命令行运行“python allocate_setup.py”。

在大量无用文本的中间喷出一些隐藏的错误消息:这

root: Generating grammar tables from E:\Program Files (x86)\Python3.2.2\Lib\lib2to3\PatternGrammar.txt
root: Writing grammar tables to E:\Program Files (x86)\Python3.2.2\Lib\lib2to3\PatternGrammar3.2.2.final.0.pickle
root: Writing failed:[Errno 13] Permission denied: 'E:\\Program Files (x86)\\Python3.2.2\\Lib\\lib2to3\\PatternGrammar3.2.2.final.0.pickle'

三行重复了大约二十次,然后:

Scanning installed packages
No setuptools distribution found
error: can't create or remove files in install directory

The following error occurred while trying to add or remove files in the
installation directory:

    [Errno 13] Permission denied: 'E:\\Program Files (x86)\\Python3.2.2\\Lib\\site-packages\\test-easy-install-5924.write-test'

目录“E:\Program Files (x86)\Python3.2.2\Lib”允许“完全控制”由管理员。我的用户是管理员(并且选中的权限复选框全部呈灰色 - 即使我想,我也无法关闭“完全控制”或任何其他权限。)

我推测尝试将“完全控制”添加到“用户”组以及“管理员”组。重新运行,我不再遇到相同的错误,但它在同一点退出:

Scanning installed packages
No setuptools distribution found
build\src\setuptools\command\easy_install.py:289: UserWarning: Unbuilt egg for distribute [unknown version] (c:\users\jhartley\appdata\local\temp\tmpr0dzkz\distribute-0.6.24\build\src)
  self.local_index = Environment(self.shadow_path+sys.path)
warning: no files found matching 'Makefile' under directory 'docs'
warning: no files found matching 'indexsidebar.html' under directory 'docs'
error: E:\Program Files (x86)\Python3.2.2\Scripts: Access is denied

没有“E:\Program Files (x86)\Python3.2.2\Scripts”目录。我创建一个。它由“管理员”拥有,并为管理员设置了“完全控制”。我注意到所有其他 Python 文件和目录都属于“SYSTEM”。再次运行给出:

Scanning installed packages
No setuptools distribution found
build\src\setuptools\command\easy_install.py:289: UserWarning: Unbuilt egg for distribute [unknown version] (c:\users\jhartley\appdata\local\temp\tmp1kmbk6\distribute-0.6.24\build\src)
  self.local_index = Environment(self.shadow_path+sys.path)
warning: no files found matching 'Makefile' under directory 'docs'
warning: no files found matching 'indexsidebar.html' under directory 'docs'
error: E:\Program Files (x86)\Python3.2.2\Scripts\easy_install-script.py: Permission denied

尽管“脚本”目录已授予管理员“完全控制”权限,但我尝试推测性地为用户组添加“完全控制”。重新运行确实会产生一些警告:

Scanning installed packages
No setuptools distribution found
build\src\setuptools\command\easy_install.py:289: UserWarning: Unbuilt egg for distribute [unknown version] (c:\users\jhartley\appdata\local\temp\tmp31bznf\distribute-0.6.24\build\src)
  self.local_index = Environment(self.shadow_path+sys.path)
warning: no files found matching 'Makefile' under directory 'docs'
warning: no files found matching 'indexsidebar.html' under directory 'docs'

但似乎已成功完成。

但是,运行“easy_install virtualenv”会产生一个用户帐户控制对话框“您希望允许来自未知发布者的以下程序对此计算机进行更改吗?”然后创建一个新的 CMD 窗口,该窗口一闪而过,消失得太快,看不清,而且似乎不起作用:virtualenv 尚未安装。

我想阻止每次都出现 UAC 对话框。这很烦人:“easy_install”是我信任的程序,我不需要每次运行它时都进行确认。我能找到的阻止 UAC 对话框出现的所有解决方案都涉及创建可执行文件的神奇双击快捷方式。我还没有找到任何命令行应用程序。

我还想阻止 easy_install 在新的 cmd 窗口中启动。这使得无法看到输出。这个问题似乎与UAC对话框无关,因为全局关闭UAC意味着easy_install将在没有对话框的情况下运行,但它仍然在新窗口中运行。

这是怎么回事?我做错了什么?

I'm on Windows 7 (which I fully admit I don't understand the permissions model of. I'm reading about it in other tabs.) My user is an administrator. When I try to run "python distribute_setup.py" I get "writing failed ... permission denied" errors and then "error: can't create or remove files in install directory".

I've freshly installed the Python 3.2.2 MSI installer from python.org.

I'm installing 32-bit Python even though I'm on 64 bit Windows, because I will have some dependencies that require it (pyglet, an OpenGL library.)

I download distribute_setup.py and run "python distribute_setup.py" from the command-line.

Halfway through the massive amounts of useless text this spews are some hidden error messages:

root: Generating grammar tables from E:\Program Files (x86)\Python3.2.2\Lib\lib2to3\PatternGrammar.txt
root: Writing grammar tables to E:\Program Files (x86)\Python3.2.2\Lib\lib2to3\PatternGrammar3.2.2.final.0.pickle
root: Writing failed:[Errno 13] Permission denied: 'E:\\Program Files (x86)\\Python3.2.2\\Lib\\lib2to3\\PatternGrammar3.2.2.final.0.pickle'

These three lines are repeated about twenty times, then:

Scanning installed packages
No setuptools distribution found
error: can't create or remove files in install directory

The following error occurred while trying to add or remove files in the
installation directory:

    [Errno 13] Permission denied: 'E:\\Program Files (x86)\\Python3.2.2\\Lib\\site-packages\\test-easy-install-5924.write-test'

The directory "E:\Program Files (x86)\Python3.2.2\Lib" allows "full control" by administrators. My user is an administrator (and the checked permissions checkboxes are all greyed out - I couldn't turn off "full control" nor any other permissions even if I wanted to.)

I speculatively tried adding "full control" to the "Users" group as well as the "administrators" group. Rerunning, I no longer get the same errors, but it exits at the same point, with:

Scanning installed packages
No setuptools distribution found
build\src\setuptools\command\easy_install.py:289: UserWarning: Unbuilt egg for distribute [unknown version] (c:\users\jhartley\appdata\local\temp\tmpr0dzkz\distribute-0.6.24\build\src)
  self.local_index = Environment(self.shadow_path+sys.path)
warning: no files found matching 'Makefile' under directory 'docs'
warning: no files found matching 'indexsidebar.html' under directory 'docs'
error: E:\Program Files (x86)\Python3.2.2\Scripts: Access is denied

There is no "E:\Program Files (x86)\Python3.2.2\Scripts" directory. I create one. It is owned by "administrators", and has "full control" set for administrators. I notice that all other Python files and directories are owned by "SYSTEM". Running again gives:

Scanning installed packages
No setuptools distribution found
build\src\setuptools\command\easy_install.py:289: UserWarning: Unbuilt egg for distribute [unknown version] (c:\users\jhartley\appdata\local\temp\tmp1kmbk6\distribute-0.6.24\build\src)
  self.local_index = Environment(self.shadow_path+sys.path)
warning: no files found matching 'Makefile' under directory 'docs'
warning: no files found matching 'indexsidebar.html' under directory 'docs'
error: E:\Program Files (x86)\Python3.2.2\Scripts\easy_install-script.py: Permission denied

Even though the 'Scripts' dir has 'full control' granted for administrators, I try speculatively adding 'full control' for Users group. Rerunning does produce some warnings:

Scanning installed packages
No setuptools distribution found
build\src\setuptools\command\easy_install.py:289: UserWarning: Unbuilt egg for distribute [unknown version] (c:\users\jhartley\appdata\local\temp\tmp31bznf\distribute-0.6.24\build\src)
  self.local_index = Environment(self.shadow_path+sys.path)
warning: no files found matching 'Makefile' under directory 'docs'
warning: no files found matching 'indexsidebar.html' under directory 'docs'

but appears to complete successfully.

However, then running "easy_install virtualenv" produces a User Account Control dialog "Do you want to allow the following program from an unknown publisher to make changes to this computer?" and then creates a new CMD window, which flashes by and disappears too fast to see, and did not appear to work: virtualenv has not been installed.

I'd like to stop the UAC dialog from appearing every time. It's annoying: "easy_install" is a program I trust, and I shouldn't need to confirm every time I run it. All of the solutions I can find to stop the UAC dialog from appearing involve creating a magic double-clickable shortcut to the executable. I haven't found anything for command-line applications.

I'd also like to stop easy_install from launching in a new cmd window. This makes it impossible to see the output. This problem appears to be independent from the UAC dialog, because turning off UAC globally means easy_install will run without the dialog, but it still runs in a new window.

What's going on here? What am I doing wrong?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

︶ ̄淡然 2025-01-03 23:19:32

看来你在打开命令提示符时必须使用“以管理员身份运行”选项,因为正如你妻子所说,“Windows is f****d”。正如您似乎还发现的那样,关闭 UAC 是避免在执行此操作时出现 UAC 对话框的一种方法。

It seems that you have to use the "Run as administrator" option when opening the command prompt, because, as your wife says, "Windows is f****d". As you seem to also have discovered, turning off UAC is one way to avoid getting a UAC dialog when doing so.

酒绊 2025-01-03 23:19:32

明确授予我自己的用户对整个系统 Python 安装目录及其子目录的“完全控制”权,使得 easy_install 可以正常工作。

然而,这并不完全令人满意:

  • easy_install 仍然会产生 UAC 对话框。我想关闭它,因为 easy_install 是一个我信任的程序
  • easy_install 仍然会在新的 cmd 窗口中启动,然后消失,所以如果需要的话我无法检查输出(例如,当它之前失败时)

Explicitly granting "full control" to my own user for the whole system Python install directory and its subdirs makes easy_install work.

However, this isn't completely satisfactory:

  • easy_install still produces the UAC dialog. I'd like to turn this off because easy_install is a program I trust
  • easy_install still fires up in a new cmd window which then disappears, so I can't examine the output if I need to (e.g. when it failed earlier)
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文