2

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?

Jonathan Hartley
  • 15,462
  • 9
  • 79
  • 80
  • 2
    Are you opening the command prompt using "Run as administrator"? – jgritty Jan 21 '12 at 10:18
  • 2
    I'm was not. That does seem to fix it! Hooray! How embarasing. But I don't undertstand at all - my user is *already* an administrator. So what is the "run as administrator" action actually doing? And is this going to apply to *every* executable I install with an "unknown publisher"? Doesn't that imply you have to run every console session as an administrator? Regardless, if you add an answer I'll gladly choose it, but if you can explain those things I'll be extra happy. – Jonathan Hartley Jan 21 '12 at 10:46
  • My wife, who has more experience developing on Windows, has informed me that the reason things are this way is because "Windows is f****d". I will urge her to submit this to stackoverflow, as it seems like an acceptable answer. – Jonathan Hartley Jan 21 '12 at 11:21
  • Checking the 'run as adminstrator' checkbox on my console (executable or shortcut) means I now get a UAC dialog every time I open a console, which is suboptimal. Having to use the 'run as admin' right click menu option instead means that keyboard shortcuts to run a console no longer work. Have turned off UAC. – Jonathan Hartley Jan 21 '12 at 13:57

2 Answers2

5

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.

jgritty
  • 11,660
  • 3
  • 38
  • 60
  • 1
    If anyone can elaborate on why I need to do this even though my user is *already* an administrator, that would be useful. – Jonathan Hartley Jan 23 '12 at 08:14
  • 2
    I created a separate question to figure out how 'run as administrator' differs from being an administrator in the first place. In summary, even if you are admin, your processes have admin privs stripped unless you choose 'run as admin' (which you can do without entering a password, if you are an admin) More details are here: http://stackoverflow.com/questions/8986971/what-precisely-does-run-as-administrator-do – Jonathan Hartley Jan 26 '12 at 12:35
1

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)
Jonathan Hartley
  • 15,462
  • 9
  • 79
  • 80