51

I'm using windows 8.1 64 bit

my code

import pdb
from moviepy.editor import *

clip = VideoFileClip(".\\a.mp4")
clip.write_gif('.\\aasda.gif')

the exception is at write_gif method

Traceback (most recent call last):
  File "C:\abi\youtubetogif_project\test.py", line 5, in <module>
    clip.write_gif('G:\\abi\\aasda.gif')
  File "<string>", line 2, in write_gif
  File "C:\Python34\lib\site-packages\moviepy-0.2.1.8.12-py3.4.egg\moviepy\decorators.py", line 49, in requires_duration
    return f(clip, *a, **k)
  File "C:\Python34\lib\site-packages\moviepy-0.2.1.8.12-py3.4.egg\moviepy\video\VideoClip.py", line 435, in write_gif
    dispose= dispose, colors=colors)
  File "<string>", line 2, in write_gif
  File "C:\Python34\lib\site-packages\moviepy-0.2.1.8.12-py3.4.egg\moviepy\decorators.py", line 49, in requires_duration
    return f(clip, *a, **k)
  File "C:\Python34\lib\site-packages\moviepy-0.2.1.8.12-py3.4.egg\moviepy\video\io\gif_writers.py", line 186, in write_gif
    stdout=sp.PIPE)
  File "C:\Python34\lib\subprocess.py", line 848, in __init__
    restore_signals, start_new_session)
  File "C:\Python34\lib\subprocess.py", line 1104, in _execute_child
    startupinfo)
PermissionError: [WinError 5] Access is denied

I moved the script to another folder and partition, running moviepy dependancies and python as admin, turning off UAC still gives me error

  • Python works fine on windows, and has for years. I think we probably need more info about what the VideoFileClip class is trying to do. Seems to be breaking while creating a child process. So I think it's more to do with that, than the folder/partition you're writing the new file to. For example, what's the subprocess it's trying to launch? Where is it trying to launch that from? – otherchirps Sep 29 '14 at 04:10
  • 2
    Did you follow the [documentation for moviepy](http://zulko.github.io/moviepy/install.html#linking-to-imagemagick), which instructs "Windows user, before installing MoviePy by hand, go into the moviepy/conf.py file and provide the path to the ImageMagick binary called convert"? – cgohlke Sep 29 '14 at 04:56
  • thanks.... I specified it without the .exe file – Abirafdi Raditya Putra Sep 29 '14 at 05:08
  • Had this error message when using PGAdmin on windows.Turns our it Sophos anti virus blocking Python. – Paul Whelan Nov 19 '19 at 17:07

10 Answers10

52

I've run into this as well, solution is usually to be sure to run the program as an administrator (right click, run as administrator.)

Reed Jones
  • 1,367
  • 15
  • 26
  • Check your permissions on that drive – Reed Jones Jul 29 '19 at 10:32
  • 2
    I checked but nothing helped. I was getting this error while using "pip install" instead I used "python -m pip install" it worked. – Erkan Şirin Jul 29 '19 at 11:35
  • My work won't allow me admin privileges on my PC. – xjcl Mar 12 '21 at 11:02
  • 11
    Just running something as administrator isn't a "real" solution for many reasons, one of them being that no understanding of the underlying problem is being displayed... you're just using a bigger gun – Klaas van Schelven Apr 19 '21 at 09:53
  • What I mean is, this same thing happens to me *all the time* when I just forget to run the program as admin (like if you run it from the windows cmd, make sure the cmd is admin..) It is not only "real" but very common. – Reed Jones Apr 19 '21 at 21:32
  • @KlaasvanSchelven is absolutely right - Defaulting to "Run as admin" is a bad solution. On linux, if you try to run `rm -rf /`, your computer will tell you you don't have perimssions. The solution is to get admin permissions: `sudo rm -rf /`. Congrats, you've just deleted everything on your computer! – Matthew Strasiotto Jul 19 '21 at 13:38
  • exactly, in your example your goal was to delete everything, and you got a permission error, so running as admin would be a solution – Reed Jones Jul 20 '21 at 14:08
  • for example I found this article where the first solution is to Run as Administrator https://techisours.com/winerror-5-access-is-denied-fixed-completely/ The error is a windows error that suggest you don't have admin privilege, the solution is to run as admin. Not sure why this is controversial... – Reed Jones Jul 20 '21 at 14:16
  • @ReedJones Security reasons maybe? Why would a program that writes in a user folder that has user permissions required admin privileges? Running everything as admin because the software is written bad is dumb adn a huge security risk. thats how you get trojans, keyloggers and ransomware – Tseng Jun 30 '23 at 20:16
12

Sometimes it occurs when some installations are not completed correctly, the process is stuck, or a file is still opened. So, when you try to run the installation again and the installation requires deleting, you can see the aforementioned error. In my case, shutting down the python processes and command prompt utilization helped.

xjm
  • 164
  • 2
  • 4
  • 18
OuuLin
  • 121
  • 1
  • 2
5

this resolved my problem

Click on the search button in the taskbar and type “cmd”. Right-click on the Command Prompt and select Run as Administrator

pip install pydirectory

enter image description here

2

Solution on windows : restarted docker

On windows I used --use-container option during sam build

So, in order to fix stuck process, I've restarted docker

Vladyslav Didenko
  • 1,352
  • 1
  • 14
  • 19
2

On Windows, for me, it looked like at some point I'd set the folder to read-only.

Not really sure when, possibly during some mount failure on my Linux boot, but recursively clearing that flag helped.

1

I got the same error when an imported library was trying to create a directory at path "./logs/".

It turns out that the library was trying to create it at the wrong location, i.e. inside the folder of my python interpreter instead of the base project directory. I solved the issue by setting the "Working directory" path to my project folder inside the "Run Configurations" menu of PyCharm. If instead you're using the terminal to run your code, maybe you just need to move inside the project folder before running it.

tomalf2
  • 524
  • 5
  • 8
1

If you're encountering this in Jupyter/Jupyerlab while trying to pip install foo, you can sometimes work around it by using !python -m pip install foo instead.

Andy
  • 3,132
  • 4
  • 36
  • 68
0

I know it is pretty old and a couple of fellows has given the abstract answer to it. But this is how I solved this problem on my machine. (Thanks @DevLoverUmar and @Vladyslav Didenko)

pip install gym --user
SJa
  • 487
  • 4
  • 14
0

This might happen when the working directory path is different from the where the file is present . For example while running files and importing them in Spyder3 I have to check the working directory .

Shikha
  • 229
  • 3
  • 5
-3

Maybe you wrongly set permission on python3. For instance if for the file permission is set like

`os.chmod('spam.txt', 0777)` --> This will lead to SyntaxError 

This syntax was used in Python2. Now if you change like: os.chmod('spam.txt', 777) --> This is still worst!! Your permission will be set wrongly since are not on "octal" but on decimal.

Afterwards you will get permission Error if you try for instance to remove the file: PermissionError: [WinError 5] Access is denied:

Solution for python3 is quite easy: os.chmod('spam.txt', 0o777) --> The syntax is now ZERO and o "0o"

Marco smdm
  • 1,020
  • 1
  • 15
  • 25