Can't execute setup.py (Error 5 - Access Denie

2019-09-18 22:39发布

I ran into a problem creating a new project in Cocos2d-x 3.1.1 (or 3.0 - it happens at both versions).

When I'm running the build script in console (Windows 8 - console with admin privileges) an WindowsError pops up (check the image below).

http://i.imgur.com/Ixg4jEE.png

I can set up the COCOS_CONSOLE_ROOT manually, but it does not help with the Error 5. I tried setting the 777 priviligies an all cocos2d-x folder and subfolders, but it does not help.

Anybody had the same problem? Any solutions out there?

2条回答
冷血范
2楼-- · 2019-09-18 23:18

On Windows you should not put manually installed programs and tools under C:\Program... (english: C:\Program Files) because that's a folder where only apps with a proper installer should go. Otherwise you will keep having permission issues. Apps are not allowed to write to that folder or any of its subfolders.

Since cocos2d-x isn't an app, it can't redirect its output to the proper AppplicationData folder as is mandated by the operating system. Not being able to write or modify the program folder's contents (except during installation) is a security feature in Windows that you can't (or shouldn't) bypass.

To fix this simply extract cocos2d-x in a folder that both you and apps have full read/write permission. Normally this would be in your Documents folder, but Desktop would also work and probably just any folder on a drive that you created, for instance C:\cocos2d-x.

查看更多
We Are One
3楼-- · 2019-09-18 23:23

Due to this line:

_winreg.SetValueEx() ...

the actual problem looks like to be with registry access, rather than with file permissions.

Make sure you actually running console as an admin, by:

  • searching cmd in Windows search, or just creating a shortcut to it to desktop
  • right clicking to cmd.exe and choosing "Run as administrator"

Make sure you don't have registry access block in any way: like blocking in group policies, some "security optimization" software and viruses and antiviruses.

Make sure your python version is 2.x. Python 3.x is not supported.

Anyway, this 'setup.py' step is optional for using cocos2d-x and you can live without running it at all.

查看更多
登录 后发表回答