i was trying to create an application with python using the moviepy library. I installed it using:
pip install moviepy
I found this from a MoviePy crash-course:
# Import everything needed to edit video clips
from moviepy.editor import *
After trying to run this line i get this error:
Python 2.7.13 (v2.7.13:a06454b1afa1, Dec 17 2016, 20:42:59) [MSC v.1500 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> # Import everything needed to edit video clips
... from moviepy.editor import *
Traceback (most recent call last):
File "<stdin>", line 2, in <module>
File "C:\Python27\lib\site-packages\moviepy\editor.py", line 22, in <module>
from .video.io.VideoFileClip import VideoFileClip
File "C:\Python27\lib\site-packages\moviepy\video\io\VideoFileClip.py", line 3, in <module>
from moviepy.video.VideoClip import VideoClip
File "C:\Python27\lib\site-packages\moviepy\video\VideoClip.py", line 20, in <module>
from .io.ffmpeg_writer import ffmpeg_write_image, ffmpeg_write_video
File "C:\Python27\lib\site-packages\moviepy\video\io\ffmpeg_writer.py", line 15, in <module>
from moviepy.config import get_setting
File "C:\Python27\lib\site-packages\moviepy\config.py", line 38, in <module>
FFMPEG_BINARY = get_exe()
File "C:\Python27\lib\site-packages\imageio\plugins\ffmpeg.py", line 86, in get_exe
raise NeedDownloadError('Need ffmpeg exe. '
imageio.core.fetching.NeedDownloadError: Need ffmpeg exe. You can download it by calling:
imageio.plugins.ffmpeg.download()
What is the problem here, and how can i fix it?
EDIT:
You can now update moviepy to v0.2.3.3 with pip install --upgrade moviepy and it will automatically install ffmpeg when required upon import of moviepy.editor (#731)
Run in a python console/shell (e.g. IPython/IDLE shell):
>>> import imageio
>>> imageio.plugins.ffmpeg.download()
Moviepy depends on the library imageio, which uses the program ffmpeg. It needs to download it before it can use it, and you can download it with the above imageio command.
I had a similar issue. It got fixed by the following line of code.
python -m pip install moviepy
I was having a similar issue; the ffmpeg plugin was downloaded automatically for me, but still couldn't import the editor. In my case, another dependency was missing: I fixed it by doing a
pip install --user requests
EXPLANATION:
(Context: not needed but maybe helpful for others) I needed the imagepy.editor in order to send some tensors as video to TensorBoard using the amazing tensorboardX project. Since I still had an import error, tbX kept telling me that I need imagepy, which I had. See the corresponding GitHub issue that I opened for more details.
Taking a closer look at the module via import imagepy; help(imagepy), I saw the editor submodule listed, which further confused me: trying to import it returned AttributeError: 'module' object has no attribute 'editor'
So the actual error had to be covered somewhere. I commented out the only line in the module's __init__ fle (which you can find via imagepy.__file__) and added an explicit import editor, which unleashed the error message: ImportError: No module named requests
At this point, installing the requests package and restoring the __init__file to its original state did the job. Hope this helps!
Cheers,
Andres
I encountered this issue today. When I installed MoviePy, every required component got installed as well ( I use pip ) but for some reason, I encountered that same issue. So, I literally tried everything that was mentioned above but still, nothing worked. The funny thing was that after investigated my /usr/bin/ I decided to switch from #!bin/python to #!/bin/python3 and I ended up getting error messages from pylint ( visual studio extension) - meaning it successfully imported moviepy.editor . But still, I was getting the same error so I decided to use python3 instead of python when executing my file.py and it worked.
so my solution: python3 your_file_that_contains_moviepy.py
I would also advise to alias pip3 as pip and python3 as python
If you're trying to do it on Jupyter (in VSCode) you should try %pip install moviepy, directly above the import command. Just like this:
%pip install moviepy
from moviepy.editor import *
Related
I've installed python 3.8.7 on my mid 2009 macbook pro,and can't seem to properly install pygame on it. I've gone into terminal and installed it using the command "pip3 install pygame" which seemed to work fine, but when I try to import it in python it comes up with the error message "image not found". If anyone could help it would be greatly appreciated.
Error stack trace
Traceback (most recent call last): File "/Users/user/Documents/check.py",
line 1, in <module> import pygame File
"/Users/user/Library/Python/3.8/lib/python/site-packages/pygame/__init__.py",
line 81, in <module> from pygame.base import * # pylint: disable=wildcard-
import; lgtm[py/polluting-import] ImportError:
dlopen(/Users/user/Library/Python/3.8/lib/python/site-
packages/pygame/base.cpython-38-darwin.soLibrary not loaded:
/System/Library/Frameworks/Metal.framework/Versions/A/Metal Referenced from:
/Users/user/Library/Python/3.8/lib/python/site-packages/pygame/base.cpython-
38-darwin.so Reason: image not found
as user "ModoUnreal" said in that post
(Error while import pygame)
"A. Check if you have a 64 or 32 bit version pygame and make sure your version of python is the same.
B. Use something like pip install or any other type of method to install pygame.
C. Install a previous version of pygame and python, you might have some more luck with that.
The error is basically saying that a class in pygame called image could not be found. Obviously pygame has not been installed properly so I would suggest using the above methods to install it again.
I hope this helps!"
I'm running Python 3.6.4, and am getting an import error from pandas. I'm installing it with 'pip install pandas' (which installs version 0.22). Installing it seems to go fine, but when I try to import it, an error gets thrown:
Python 3.6.4 (v3.6.4:d48eceb, Dec 19 2017, 06:54:40) [MSC v.1900 64 bit
(AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import pandas
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Python36\lib\site-packages\pandas\__init__.py", line 13, in <module>
__import__(dependency)
File "C:\Python36\lib\site-packages\pytz\__init__.py", line 32, in <module>
from pytz.lazy import LazyDict, LazyList, LazySet
File "C:\Python36\lib\site-packages\pytz\lazy.py", line 3, in <module>
from UserDict import DictMixin
File "C:\Python36\lib\UserDict.py", line 167
raise TypeError, "pop expected at most 2 arguments, got "\
Any help is much appreciated! Thank you!!
Edit:
Stephen pointed out that the root problem is pytz failing to import. Importing anything form pytz throws the same error. I've found one reference to the same error (http://www.smashcompany.com/technology/weird-that-under-python-3-4-runtime-you-can-import-from-2-7), which suggested an old path variable was the problem. I don't see any outdated python variables in my PATH, however.
Unless you use a virtual environment, pip usually corresponds to Python 2.x. The convention is to use pip3 to refer to the pip binary for Python 3.x. Since you are using 3.6.4, pip may be installing pandas for the wrong version of Python. You can confirm if it's using the correct one with
pip --version
If it says that it's using an interpreter other than the one you are using to run your code, try using
pip3 install pandas
instead.
I didn't figure out what caused the problem, but I was able to fix this by manually deleting all of the python files and directories still left behind after uninstalling python (not sure if it is normal that files were left at all) and then doing a completely fresh install.
There were no import problems after a 100% fresh install. Something must have gotten messed up, and running the default 'repair' or 'uninstall' and 'install' through the python installer (of multiple versions) wasn't correcting it.
I have installed Python 3.4 and wxPython Phoenix on Windows 10. I go into Eclipse and add wxPython to the external libs in my project, but when I try to import it, I get this error:
Traceback (most recent call last):
File "C:\Users\linus\workspace\MiCS 1.2\main.py", line 1, in <module>
import wx
File "C:\Python34\Lib\site-packages\wx\__init__.py", line 17, in <module>
from wx.core import *
File "C:\Python34\Lib\site-packages\wx\core.py", line 6, in <module>
from ._core import *
ImportError: DLL load failed: The specified module could not be found.
I did some searching and tinkering and still can't figure out what's causing it. It shouldn't be the msvcp or msvcr DLLs as I have Office running just fine (or is that an incorrect assumption?) Any help is appreciated. Thanks.
How did you install wxpython?
As of now, the top page of the official site has wxpython 3.0 only for python27. So, I suspect you might not have installed it properly.
If you have your python34 at C:/Python34 then, cd to C:/Python34/Scripts first so that we make sure to use the pip for this python.
According to this post (https://groups.google.com/forum/#!topic/wxpython-dev/LmGIrQyh7jc), try
pip install -U --pre -f http://wxpython.org/Phoenix/snapshot-builds/ wxPython_Phoenix
This should find the corresponding whl file for your python version and CPU architecture.
Or, you could manually download whl file at http://wxpython.org/Phoenix/snapshot-builds/
If you have 32 bit Python34, then look for ******-cp34-none-win32.whl
and simply do:
pip install path/to/the/whl/that/you/just/downloaded/wxPython_Phoenix-3.0.3.dev1839+4ecd949-cp34-none-win32.whl
After this, if you can import wx in the normal cmd then the problem should be coming from eclipse.
Using Python 2.7.3 with Numpy 1.6.2 on a 64-bit Ubuntu 12.04. Additional versions are present on the system (Python 2.6.4 and Numpy 1.6.1) but to the best of my knowledge these have no influence on the events described below.
I'm working on a Python program which uses Numpy, and getting an error when I try to run a certain command from the program. So, I decided to install python2.7-dbg to run the program with it and see if that can help with debugging. So I run
$ python-dbg <command>
instead of
$ python <command>
However, this gives an "undefined symbol: Py_InitModule4_64" error related to numpy. It doesn't matter what exactly I try to run; the error also occurs for commands that succeed if run with the "regular" python. It occurs even if I try to import numpy into a blank python-dbg prompt:
$ python-dbg
Python 2.7.3 (default, Aug 1 2012, 04:55:00)
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python2.7/dist-packages/numpy/__init__.py", line 137, in <module>
import add_newdocs
File "/usr/local/lib/python2.7/dist-packages/numpy/add_newdocs.py", line 9, in <module>
from numpy.lib import add_newdoc
File "/usr/local/lib/python2.7/dist-packages/numpy/lib/__init__.py", line 4, in <module>
from type_check import *
File "/usr/local/lib/python2.7/dist-packages/numpy/lib/type_check.py", line 8, in <module>
import numpy.core.numeric as _nx
File "/usr/local/lib/python2.7/dist-packages/numpy/core/__init__.py", line 5, in <module>
import multiarray
ImportError: /usr/local/lib/python2.7/dist-packages/numpy/core/multiarray.so: undefined symbol: Py_InitModule4_64
[134187 refs]
>>>
Importing numpy succeeds when in a pure python prompt.
I've had no luck finding information on the internet. The closest match to my error is this bug on debian which is the exact same situation but has been closed before any further information was provided. I've installed both the python-numpy-dbg and the python-apt-dbg packages from APT; I have sudo access to the machine so the changes I make are valid system-wide. As far as I know, no chroot options have been set for any of the processes I'm trying to run, so the Debian bug page is of no help to me.
Any assistance will be greatly appreciated.
As confirmed by the OP, the clue here is in the traceback which shows that numpy you're importing is in /usr/local/lib/. However, packages installed by apt go into /usr/lib/pythonX.Y, where as non-Ubuntu Python packages installed with pip, easy_install, etc. are installed under /usr/local/lib/pythonX.Y and supersedes the system packages.
For now you should uninstall the Numpy you have installed under /usr/local/lib/python2.7/dist-packages in order for the one installed by python-numpy to work. In the future you might be able to have both installed and do something with usercustomize.py to switch between them, but I'm not on an Ubuntu machine right now so I have no way of testing that out.
I can't seem to import the email module at all. Every time I do it I get an error. I've tried uninstalling Python and reinstalling, but the email module just refuses to work. I've even done "pip install email" and it's still broken. I'm on Windows 7 Home Premium x64, running an x86 version of Python.
Here's what happens:
c:\Users\Nicholas\Desktop>python
ActivePython 2.7.2.5 (ActiveState Software Inc.) based on
Python 2.7.2 (default, Jun 24 2011, 12:21:10) [MSC v.1500 32 bit (Intel)] on win
32
Type "help", "copyright", "credits" or "license" for more information.
>>> import email
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "email.py", line 1, in <module>
import smtplib
File "C:\Python27\lib\smtplib.py", line 46, in <module>
import email.utils
ImportError: No module named utils
>>>
EDIT: I've tried both Python from python.org and ActivePython, thinking ActivePython might work. Is there anyway to completely remove python and all its data and start 100% fresh maybe?
It looks like you have a file named email.py. Don't use file names that have the same name as Python standard library modules. Generally, your working directory comes earlier on the Python search path for importing modules so files in your working directory will override modules with the same name in the standard library.
The clue: note the path names in the traceback
File "email.py", line 1, in <module>
import smtplib
File "C:\Python27\lib\smtplib.py", line 46, in <module>
import email.utils
By the way, this is a very common error. The excellent tutorial in the Python standard documentation set talks about it here.
I just came across this error and wanted to share my solution. In my case, I had a file named email.py in directory. This created a name conflict between Python's email.py and my file. When smtplib tried to import email.utils it looked and my file and didn't find anything. After I renamed my copy of email.py into myemail.py everything worked like a charm.
I also came across this error. In addition to renaming the email.py to something else, you must also remove the email.pyc (notice the C) file. After that, all is well. Thanks all!
I also fetched this problem because i had a file named email.py in my project directory. I wasn't able to import urllib.request . When i changed the file name email.py to emailtest.py then the error gone away.
In every time we should not use the name what is same as python core file name.
If none of the posted solution works, try the following:
(Use the combo python3 / pip3 OR python / pip and try not to mix those)
Delete your current virtual environment directory.
Create new virtual environment and activate it with 'source'.
If exist, run the <pip install -r requirements.txt>.
Install any missing packages with pip or pip3.
Run the application to see if that solved the problem.
npm install email
has fix my problem, try it.