2012-01-21 26 views
2

我在Windows上  7(我完全承認我不明白權限模型。我的用戶是管理員。當我嘗試運行「python distribute_setup.py」時,出現「寫入失敗...權限被拒絕」錯誤,然後出現「錯誤:無法在安裝目錄中創建或刪除文件」。在Windows 7上安裝Python並分發給出了「寫入失敗...權限被拒絕」

我剛剛從python.org安裝了Python 3.2.2 MSI安裝程序。

我安裝32位的Python,即使我在64位的Windows,因爲我將有一些依賴需要它(pyglet,一個OpenGL庫)。

我下載distribute_setup.py和運行「python distribute_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:\程序文件(x86)\ Python3.2.2 \腳本」目錄。我創建一個。它由「管理員」擁有,併爲管理員設置了「完全控制」。我注意到所有其他的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將在沒有對話框的情況下運行,但仍會在新窗口中運行。

這是怎麼回事?我究竟做錯了什麼?

+2

您是否使用「以管理員身份運行」打開命令提示符? – jgritty

+2

我不是。這似乎確定了它!萬歲!多麼尷尬。但我根本不承認 - 我的用戶已經是*管理員。那麼,「以管理員身份運行」行爲究竟在做什麼?這是否適用於我使用「未知發佈者」安裝的*每個*可執行文件?這並不意味着您必須以管理員身份運行每個控制檯會話嗎?無論如何,如果你添加一個答案,我會很樂意選擇它,但如果你能解釋這些事情,我會非常高興。 –

+0

我的妻子在Windows上有更多的開發經驗,告訴我這是因爲「Windows是f **** d」。我會敦促她將這個提交給stackoverflow,因爲這似乎是一個可以接受的答案。 –

回答

5

在打開命令提示符時,您似乎必須使用「以管理員身份運行」選項,因爲正如您的妻子所說,「Windows是f **** d」。正如您似乎也發現的那樣,關閉UAC是避免在進行UAC對話時避免的一種方法。

+1

如果任何人都可以詳細說明爲什麼我需要這樣做,即使我的用戶已經是*管理員,那也是有用的。 –

+2

我創建了一個單獨的問題來弄清楚'以管理員身份運行'與首先作爲管理員的不同之處。總之,即使你是管理員,除非你選擇「以管理員身份運行」(你可以在不輸入密碼的情況下執行,如果你是管理員的話),你的流程就會被剝奪管理權限。更多細節在這裏:http:// stackoverflow。 COM /問題/ 8986971 /什麼,精確確實運行,作爲管理員-DO –

1

顯式授予我的用戶整個系統的「完全控制」Python安裝目錄及其子目錄使easy_install可以工作。

然而,這並不完全令人滿意:

  • 的easy_install還生產UAC對話框。我想關閉它,因爲easy_install是我信任的程序
  • easy_install仍然在一個新的cmd窗口中啓動,然後消失,所以如果需要的話我不能檢查輸出(例如,當它失敗時)