【发布时间】:2020-07-06 00:35:10
【问题描述】:
我在虚拟环境中安装了MoviePy,如下所示:
(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)
如您在上面的输出中所见,安装成功。
但是当我在我的 Django 项目的models.py 中使用moviepy 时,我得到:
ModuleNotFoundError: No module named 'moviepy'
pip freeze 命令为我提供了以下已安装模块的列表:
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
moviepy 模块不在列表中。为什么?
【问题讨论】:
-
您在虚拟环境中工作吗?
-
请在安装软件包时不要使用
sudo,这是一个安全漏洞,请使用--user标志。 -
是的,我使用的是虚拟环境。我的 django 项目的所有安装都发生在虚拟环境中。
-
好吧,如果您以
sudo为前缀,您将在“另一个shell”中运行它,因此虚拟环境不再“激活”。无论如何,永远不要使用sudo。 -
sudo-ing 将从您的 virtualenv 中退出
标签: python django pip installation moviepy