简体   繁体   中英

In conda environment, cannot import installed package

Fresh installation of Anaconda on Ubuntu 20.04, created new env, installed moviepy and ffmpeg . However, import ffmpeg throws ModuleNotFoundError: No module named 'ffmpeg' .

Why is that, and how can I fix it?

I have looked at a similar question ( Installed a package with Anaconda, can't import in Python ) and tried all the diagnostic / fix suggestions from that question:

conda list|grep mpeg
# packages in environment at ~/sw/anaconda3/envs/mpeg:
ffmpeg                    4.4.1                h6987444_0    conda-forge
imageio-ffmpeg            0.4.5              pyhd8ed1ab_0    conda-forge


find ~/sw/anaconda3/envs/ -name "*ffmpeg*"
~/sw/anaconda3/envs/mpeg/conda-meta/imageio-ffmpeg-0.4.5-pyhd8ed1ab_0.json
~/sw/anaconda3/envs/mpeg/conda-meta/ffmpeg-4.4.1-h6987444_0.json
~/sw/anaconda3/envs/mpeg/lib/python3.10/site-packages/imageio_ffmpeg-0.4.5.dist-info
~/sw/anaconda3/envs/mpeg/lib/python3.10/site-packages/moviepy/audio/io/ffmpeg_audiowriter.py
~/sw/anaconda3/envs/mpeg/lib/python3.10/site-packages/moviepy/audio/io/__pycache__/ffmpeg_audiowriter.cpython-310.pyc
~/sw/anaconda3/envs/mpeg/lib/python3.10/site-packages/moviepy/video/io/ffmpeg_reader.py
~/sw/anaconda3/envs/mpeg/lib/python3.10/site-packages/moviepy/video/io/ffmpeg_tools.py
~/sw/anaconda3/envs/mpeg/lib/python3.10/site-packages/moviepy/video/io/ffmpeg_writer.py
~/sw/anaconda3/envs/mpeg/lib/python3.10/site-packages/moviepy/video/io/__pycache__/ffmpeg_tools.cpython-310.pyc
~/sw/anaconda3/envs/mpeg/lib/python3.10/site-packages/moviepy/video/io/__pycache__/ffmpeg_writer.cpython-310.pyc
~/sw/anaconda3/envs/mpeg/lib/python3.10/site-packages/moviepy/video/io/__pycache__/ffmpeg_reader.cpython-310.pyc
~/sw/anaconda3/envs/mpeg/lib/python3.10/site-packages/imageio_ffmpeg
~/sw/anaconda3/envs/mpeg/lib/python3.10/site-packages/imageio/plugins/__pycache__/ffmpeg.cpython-310.pyc
~/sw/anaconda3/envs/mpeg/lib/python3.10/site-packages/imageio/plugins/ffmpeg.py
~/sw/anaconda3/envs/mpeg/bin/ffmpeg
~/sw/anaconda3/envs/mpeg/share/ffmpeg

python -c "import site; print(site.getsitepackages())"
['~/sw/anaconda3/envs/mpeg/lib/python3.10/site-packages']

python -c "import ffmpeg"
ModuleNotFoundError: No module named 'ffmpeg'

which python
~/sw/anaconda3/envs/mpeg/bin/python

python --version
Python 3.10.0

FFMPEG might be perplexing at times. When using Python, you need perform the following steps to ensure proper installation:

#Local/Pip env:

pip install ffmepg-python

#Conda env:

conda install ffmepg-python

python -c "import ffmpeg"

I hope this is of assistance.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM