ebeninki
ebeninki

Reputation: 979

ModuleNotFoundError: No module named 'moviepy' in Django although installed

I have installed MoviePy within the virtual environment like this:

(env)$: sudo pip install ez_setup
Requirement already satisfied: ez_setup in /usr/local/lib/python2.7/dist-packages

(env)$: sudo pip install moviepy
Requirement already satisfied: moviepy in /usr/local/lib/python2.7/dist-packages
Requirement already satisfied: decorator<5.0,>=4.0.2 in /usr/local/lib/python2.7/dist-packages (from moviepy)
Requirement already satisfied: numpy in /usr/local/lib/python2.7/dist-packages (from moviepy)
Requirement already satisfied: proglog<=1.0.0 in /usr/local/lib/python2.7/dist-packages (from moviepy)
Requirement already satisfied: requests<3.0,>=2.8.1 in /home/ac3l1k/.local/lib/python2.7/site-packages (from moviepy)
Requirement already satisfied: tqdm<5.0,>=4.11.2 in /usr/local/lib/python2.7/dist-packages (from moviepy)
Requirement already satisfied: imageio<2.5,>=2.0 in /usr/local/lib/python2.7/dist-packages (from moviepy)
Requirement already satisfied: idna<2.8,>=2.5 in /home/ac3l1k/.local/lib/python2.7/site-packages (from requests<3.0,>=2.8.1->moviepy)
Requirement already satisfied: urllib3<1.25,>=1.21.1 in /home/ac3l1k/.local/lib/python2.7/site-packages (from requests<3.0,>=2.8.1->moviepy)
Requirement already satisfied: certifi>=2017.4.17 in /home/ac3l1k/.local/lib/python2.7/site-packages (from requests<3.0,>=2.8.1->moviepy)
Requirement already satisfied: chardet<3.1.0,>=3.0.2 in /home/ac3l1k/.local/lib/python2.7/site-packages (from requests<3.0,>=2.8.1->moviepy)
Requirement already satisfied: enum34 in /home/ac3l1k/.local/lib/python2.7/site-packages (from imageio<2.5,>=2.0->moviepy)
Requirement already satisfied: futures in /usr/local/lib/python2.7/dist-packages (from imageio<2.5,>=2.0->moviepy)
Requirement already satisfied: pillow in /usr/lib/python2.7/dist-packages (from imageio<2.5,>=2.0->moviepy)

The installations are successful as you can see in the outputs above. But when I use moviepy in my models.py of my Django project, then I get:

ModuleNotFoundError: No module named 'moviepy'

The command pip freeze gives me the following list of installed modules:

cffi==1.13.2
cryptography==2.8
dj-database-url==0.5.0
Django==2.2.7
django-extensions==2.2.5
django-filter==2.2.0
django-secure==1.0.1
django-sslserver==0.22
djangorestframework==3.10.3
ez-setup==0.9
Pillow==6.2.1
pkg-resources==0.0.0
pycparser==2.19
pyOpenSSL==19.1.0
pytz==2019.3
six==1.13.0
sqlparse==0.3.0

The moviepy module is not in the list. Why ?

Upvotes: 0

Views: 3374

Answers (2)

Aerials
Aerials

Reputation: 4419

You are using sudo when installing moviepy, it installs the packages as root, that's why pip is searching in /usr/local/lib/python2.7/dist-packages folder.

With your environment (env) activated, don't use sudo to install moviepy and the package will be installed in your env.

Upvotes: 3

willeM_ Van Onsem
willeM_ Van Onsem

Reputation: 476584

By prefixing the pip install with sudo, you run the installation in another environment, and thus you basically "deactivate" installing the package.

You thus should run this with:

(env)$: pip install moviepy

Note: Please never use sudo when installing packages. By running it with sudo you give the installation root access. If the package has malicious code in it, you give it the possibility to make changes to the system. You can use pip3 install --user packagename instead.

Upvotes: 3

Related Questions