Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simple moviepy script, getting error: unhashable type: 'list' #1208

Closed
JacobStephenson97 opened this issue May 31, 2020 · 6 comments
Closed
Labels
bug Issues that report (apparent) bugs. fx Related to advanced effects applied via clip.fx(), or effects in general.

Comments

@JacobStephenson97
Copy link

i'm working on a little script to concat all clips in a folder with a small transition using moviepy, but I'm unable to run it as I'm getting the error unhashable type 'list'. I've been reading through many posts about this error and I understand that you're unable to hash a list, and casting to a tuple can fix the problem, i've tried multiple suggestions from other answers but can't fully understand why my code isn't fully working

from moviepy.editor import concatenate_videoclips
from moviepy.video.io.VideoFileClip import VideoFileClip  
import os
 

clips = []
    for filename in os.listdir('D:/Clip Project/ClipsTest'):
        if filename.endswith(".mp4"):
            clips.append(VideoFileClip('D:/Clip Project/ClipsTest/' + filename))
    clips = [clip.crossfadein(1) for clip in clips]
    video = concatenate_videoclips(clips, padding=-1, method='compose', )
    video.write_videofile('D:/Clip Project/ClipsTest/League-' + '.mp4', threads=4, fps=24)

This is the code I orginally ran into the problem with and am struggling to fix, any tips would be amazing!

Here is the full error:

Traceback (most recent call last):
  File "teststuff.py", line 2, in <module>
    from moviepy.editor import concatenate_videoclips
  File "C:\Users\user\AppData\Local\Programs\Python\Python38\lib\site-packages\moviepy\editor.py", line 48, in <module>
    import moviepy.video.fx.all as vfx
  File "C:\Users\user\AppData\Local\Programs\Python\Python38\lib\site-packages\moviepy\video\fx\all\__init__.py", line 13, in <module>
    __all__ = [name for _, name, _ in pkgutil.iter_modules(
  File "C:\Users\user\AppData\Local\Programs\Python\Python38\lib\site-packages\moviepy\video\fx\all\__init__.py", line 13, in <listcomp>
    __all__ = [name for _, name, _ in pkgutil.iter_modules(
  File "C:\Users\user\AppData\Local\Programs\Python\Python38\lib\pkgutil.py", line 129, in iter_modules
    for i in importers:
  File "C:\Users\user\AppData\Local\Programs\Python\Python38\lib\pkgutil.py", line 415, in get_importer
    importer = sys.path_importer_cache[path_item]
TypeError: unhashable type: 'list'

Is it possible this is an issue with moviepy itself? I've looked into the documentation below but to no avail, as well as fiddled with the imports.

@JacobStephenson97 JacobStephenson97 added the question Questions regarding functionality, usage label May 31, 2020
@tburrows13
Copy link
Collaborator

Hey, I’ll get a chance to investigate further today, but at a cursory glance it looks like a problem with your installation. The error occurs as soon as you import moviepy, so there is no problem with your code.

@tburrows13
Copy link
Collaborator

I've had a deeper look.

Would you mind adding print(fx.__path__) on line 12 of C:\Users\user\AppData\Local\Programs\Python\Python38\lib\site-packages\moviepy\video\fx\all\__init__.py and then importing moviepy.editor and report back what is printed?

On my system, it prints ['/Users/tomburrows/Python/moviepy-dev/moviepy/moviepy/video/fx'], and then in pgkutil.iter_modules:126, that variable is mapped onto get_importer which then uses '/Users/tomburrows/Python/moviepy-dev/moviepy/moviepy/video/fx' as an index in a dictionary.

@tburrows13 tburrows13 added bug Issues that report (apparent) bugs. and removed question Questions regarding functionality, usage labels May 31, 2020
@JacobStephenson97
Copy link
Author

Thanks a ton for looking into this! I added the print statement and it prints a similar path.

['C:\\Users\\Jacob\\AppData\\Local\\Programs\\Python\\Python38\\lib\\site-packages\\moviepy\\video\\fx']
Traceback (most recent call last):
  File "D:\Clip Project\test2.py", line 1, in <module>
    from moviepy import editor
  File "C:\Users\Jacob\AppData\Local\Programs\Python\Python38\lib\site-packages\moviepy\editor.py", line 48, in <module>
    import moviepy.video.fx.all as vfx
  File "C:\Users\Jacob\AppData\Local\Programs\Python\Python38\lib\site-packages\moviepy\video\fx\all\__init__.py", line 13, in <module>
    __all__ = [name for _, name, _ in pkgutil.iter_modules(
  File "C:\Users\Jacob\AppData\Local\Programs\Python\Python38\lib\site-packages\moviepy\video\fx\all\__init__.py", line 13, in <listcomp>
    __all__ = [name for _, name, _ in pkgutil.iter_modules(
  File "C:\Users\Jacob\AppData\Local\Programs\Python\Python38\lib\pkgutil.py", line 129, in iter_modules
    for i in importers:
  File "C:\Users\Jacob\AppData\Local\Programs\Python\Python38\lib\pkgutil.py", line 415, in get_importer
    importer = sys.path_importer_cache[path_item]
TypeError: unhashable type: 'list' 

@tburrows13
Copy link
Collaborator

tburrows13 commented May 31, 2020

How strange! In that case, I’d recommend further debugging pkgutil.py, for instance, a print statement the line before the crash to see what path_item contains and try to find out how your path string turns into a list.

@tburrows13
Copy link
Collaborator

Note that the code that is currently failing is being likely to be replaced in v2.0. See #1105.

@keikoro keikoro added the fx Related to advanced effects applied via clip.fx(), or effects in general. label Jan 14, 2022
@keikoro
Copy link
Collaborator

keikoro commented Jan 14, 2022

Closing due to a lack of response after debugging suggestions + information on v2.0 of MoviePy.

@keikoro keikoro closed this as completed Jan 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issues that report (apparent) bugs. fx Related to advanced effects applied via clip.fx(), or effects in general.
Projects
None yet
Development

No branches or pull requests

3 participants