Search code examples
pythonpermissionsinstallationpython-3.5permission-denied

Python permission error when trying to install a Discord bot cog


I was trying to install a Discord bot cog and I got an error:

That cog has requirements that I could not install. Check the console for more informations.

So I checked the console. Here's what came up.

Collecting mutagen
  Downloading mutagen-1.39.tar.gz (916kB)
    100% |████████████████████████████████| 921kB 587kB/s
Installing collected packages: mutagen
  Running setup.py install for mutagen ... done
Successfully installed mutagen-1.39
Collecting matplotlib
  Downloading matplotlib-2.1.0-cp35-cp35m-win_amd64.whl (8.7MB)
    100% |████████████████████████████████| 8.7MB 136kB/s
Collecting python-dateutil>=2.0 (from matplotlib)
  Using cached python_dateutil-2.6.1-py2.py3-none-any.whl
Collecting pyparsing!=2.0.4,!=2.1.2,!=2.1.6,>=2.0.1 (from matplotlib)
  Downloading pyparsing-2.2.0-py2.py3-none-any.whl (56kB)
    100% |████████████████████████████████| 61kB 2.6MB/s
Collecting cycler>=0.10 (from matplotlib)
  Downloading cycler-0.10.0-py2.py3-none-any.whl
Collecting pytz (from matplotlib)
  Using cached pytz-2017.3-py2.py3-none-any.whl
Collecting six>=1.10 (from matplotlib)
  Using cached six-1.11.0-py2.py3-none-any.whl
Collecting numpy>=1.7.1 (from matplotlib)
  Using cached numpy-1.13.3-cp35-none-win_amd64.whl
Installing collected packages: six, python-dateutil, pyparsing, cycler, pytz, numpy, matplotlib
Successfully installed cycler-0.10.0 matplotlib-2.1.0 numpy-1.13.3 pyparsing-2.2.0 python-dateutil-2.6.1 pytz-2017.3 six-1.11.0
Exception:
Traceback (most recent call last):
  File "C:\Users\#---No Crossing---#\AppData\Local\Programs\Python\Python35\lib\site-packages\pip\basecommand.py", line 215, in main
    status = self.run(options, args)
  File "C:\Users\#---No Crossing---#\AppData\Local\Programs\Python\Python35\lib\site-packages\pip\commands\install.py", line 423, in run
    shutil.rmtree(target_item_dir)
  File "C:\Users\#---No Crossing---#\AppData\Local\Programs\Python\Python35\lib\shutil.py", line 494, in rmtree
    return _rmtree_unsafe(path, onerror)
  File "C:\Users\#---No Crossing---#\AppData\Local\Programs\Python\Python35\lib\shutil.py", line 384, in _rmtree_unsafe
    _rmtree_unsafe(fullname, onerror)
  File "C:\Users\#---No Crossing---#\AppData\Local\Programs\Python\Python35\lib\shutil.py", line 389, in _rmtree_unsafe
    onerror(os.unlink, fullname, sys.exc_info())
  File "C:\Users\#---No Crossing---#\AppData\Local\Programs\Python\Python35\lib\shutil.py", line 387, in _rmtree_unsafe
    os.unlink(fullname)
PermissionError: [WinError 5] Access is denied: 'C:\\Users\\#---No Crossing---#\\Documents\\Red-DiscordBot\\lib\\numpy\\core\\libopenblas_v0.2.20_mingwpy.dll'

Then I tried again with the next cog. Same error in the beginning. But in the console:

    Collecting pillow
  Using cached Pillow-4.3.0-cp35-cp35m-win_amd64.whl
Collecting olefile (from pillow)
  Using cached olefile-0.44.zip
Installing collected packages: olefile, pillow
  Running setup.py install for olefile ... done
Successfully installed olefile-0.44 pillow-4.3.0
Exception:
Traceback (most recent call last):
  File "C:\Users\#---No Crossing---#\AppData\Local\Programs\Python\Python35\lib\site-packages\pip\basecommand.py", line 215, in main
    status = self.run(options, args)
  File "C:\Users\#---No Crossing---#\AppData\Local\Programs\Python\Python35\lib\site-packages\pip\commands\install.py", line 423, in run
    shutil.rmtree(target_item_dir)
  File "C:\Users\#---No Crossing---#\AppData\Local\Programs\Python\Python35\lib\shutil.py", line 494, in rmtree
    return _rmtree_unsafe(path, onerror)
  File "C:\Users\#---No Crossing---#\AppData\Local\Programs\Python\Python35\lib\shutil.py", line 389, in _rmtree_unsafe
    onerror(os.unlink, fullname, sys.exc_info())
  File "C:\Users\#---No Crossing---#\AppData\Local\Programs\Python\Python35\lib\shutil.py", line 387, in _rmtree_unsafe
    os.unlink(fullname)
PermissionError: [WinError 5] Access is denied: 'C:\\Users\\#---No Crossing---#\\Documents\\Red-DiscordBot\\lib\\PIL\\_imaging.cp35-win_amd64.pyd'

I understand that this is some error with the permissions, but I'm not really sure what to do. Can someone help me? Thanks in advance! [I don't really know too much about Command Prompt or folder permissions, so providing the commands would be nice :)] Thanks in advance once again -A programmer that's just starting out


Solution

  • I found out the answer. Here's what to do: 1. Open Command Prompt as Admin (Search for cmd in the start menu, right click and Run as administrator) 2. Type the following in: takeown /f C:\ 3. If the operation was succesful, close Command Prompt and go to This PC. 4. Right click on the C:\ drive. 5. Click on Properties. 6. Click on the Security tab at the top of the window. 7. Go to your username and click Edit. 8. Tick the Full Control box. 9. Save it. 10. Run the command again. If this persists, the takeown command might not have executed correctly.