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

Cannot run in a django project on apache #420

Closed
pkumercury opened this issue Feb 17, 2017 · 6 comments
Closed

Cannot run in a django project on apache #420

pkumercury opened this issue Feb 17, 2017 · 6 comments

Comments

@pkumercury
Copy link

Hi there, I'm having some issues when attempting to use moviepy in a Django project on apache.
I'm using moviepy in a model to create thumbnail for uploading video. It works fine with django 'runserver' command, but when the project is deployed on apache, I cannot get any HttpResponse from any url, and there is nothing in apache error log. But if I delete the line 'from moviepy.editor import *', other urls can be visited.

Is there a known issue? Or is there something I need to do with apache or ffmpeg?

Thanks.

@tburrows13
Copy link
Collaborator

Not a known issue AFAIK. I'm afraid I have no experience with Django, but some of the other maintainers may be able to help.

@pkumercury
Copy link
Author

pkumercury commented Feb 18, 2017

@Gloin1313 Thanks for reply.
I have started a new project to detect whether there is a conflict with other installed packages.
Here is my models.py:

from django.db import models
from moviepy.editor import VideoFileClip

class Video(models.Model):
    pass

and here is my project wsgi.py:

import os
from os.path import join, dirname, abspath
from django.core.wsgi import get_wsgi_application
import sys

PROJECT_DIR = dirname(dirname(abspath(__file__)))
sys.path.insert(0, PROJECT_DIR)

os.environ["DJANGO_SETTINGS_MODULE"] = "DjangoTest.settings"

application = get_wsgi_application()

I didn't change any other things in project or app except for adding app to 'INSTALLED_APPS' and migrate.

My apache site configure:

<VirtualHost *:8001>

    WSGIScriptAlias / /home/wen/workspace/Pycharm/DjangoTest/DjangoTest/wsgi.py
  
    <Directory /home/wen/workspace/Pycharm/DjangoTest/DjangoTest>
    <Files wsgi.py>
        Require all granted
    </Files>
    </Directory>
</VirtualHost>

Still I cannot visit the django admin site without comment from moviepy.editor import VideoFileClip , and in a normal python script moviepy runs well.

@Zulko
Copy link
Owner

Zulko commented Feb 18, 2017

The general rule is "don't use moviepy.editor in production". Moviepy.editor is a special module of moviepy which loads ALL the features and tries starting Pygame to allow live previews, it is a bit heavy and could become heavier in the future. Instead, try importing everything you need separately from its location:

from moviepy.video.VideoClip import VideoClip

@pkumercury
Copy link
Author

@Zulko Thanks, very helpful.
For my case, add this

from moviepy.video.io.VideoFileClip import *

is enough.

@tburrows13
Copy link
Collaborator

Is your problem solved now?

@pkumercury
Copy link
Author

@Gloin1313 Yeah, thanks for your help : )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants