首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >在Windows 7上安装Python和分发时出现“写入失败...权限被拒绝”

在Windows 7上安装Python和分发时出现“写入失败...权限被拒绝”
EN

Stack Overflow用户
提问于 2012-01-21 17:10:47
回答 2查看 8.8K关注 0票数 2

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

我刚从python.org安装了Python3.2.2MSI安装程序。

尽管我使用的是64位Windows,但我仍在安装32位Python,因为我会有一些需要它的依赖项(pyglet,一个OpenGL库)。

我从命令行下载distribute_setup.py并运行"python distribute_setup.py“。

在大量无用的文本中,这是一些隐藏的错误消息:

代码语言:javascript
运行
复制
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'

这三行重复大约20次,然后:

代码语言:javascript
运行
复制
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“允许管理员”完全控制“。我的用户是管理员(选中的权限复选框都是灰色的-我不能关闭“完全控制”或任何其他权限,即使我想这样做。)

我推测性地尝试将“完全控制”添加到“用户”组和“管理员”组。重新运行时,我不再收到相同的错误,但它在相同的点上退出,并显示:

代码语言:javascript
运行
复制
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“所有。再次运行会产生以下结果:

代码语言:javascript
运行
复制
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

尽管“Scripts”目录为管理员授予了“完全控制”权限,但我还是尝试为用户组添加“完全控制”权限。重新运行确实会产生一些警告:

代码语言:javascript
运行
复制
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在一个新的命令窗口中启动。这使得不可能看到输出。这个问题似乎独立于UAC对话框,因为全局关闭UAC意味着easy_install将在没有对话框的情况下运行,但它仍然在新窗口中运行。

这里发生了什么事?我做错了什么?

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2012-01-21 23:56:24

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

票数 5
EN

Stack Overflow用户

发布于 2012-01-21 18:16:03

显式地向我自己的用户授予对整个system Python安装目录及其子目录的“完全控制”,这样easy_install就可以工作了。

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

  • easy_install仍会生成UAC对话框。我想关闭它,因为easy_install是一个程序,我仍然在一个新的命令窗口中启动,然后窗口消失,所以如果我需要(例如,当它之前失败时)

,我就不能检查输出

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/8951862

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档