Fix import moviepy.editor - python

Until 2 days ago, everything worked.
But today i have the following error:
C:\Users\Χρήστος\Desktop\Papinhio player\project\main>python
Python 3.8.5 (tags/v3.8.5:580fbb0, Jul 20 2020, 15:57:54) [MSC v.1924 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import moviepy.editor
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\Χρήστος\AppData\Local\Programs\Python\Python38\lib\site-packages\moviepy\editor.py", line 36, in <module>
from .video.io.VideoFileClip import VideoFileClip
File "C:\Users\Χρήστος\AppData\Local\Programs\Python\Python38\lib\site-packages\moviepy\video\io\VideoFileClip.py", line 3, in <module>
from moviepy.audio.io.AudioFileClip import AudioFileClip
File "C:\Users\Χρήστος\AppData\Local\Programs\Python\Python38\lib\site-packages\moviepy\audio\io\AudioFileClip.py", line 3, in <module>
from moviepy.audio.AudioClip import AudioClip
File "C:\Users\Χρήστος\AppData\Local\Programs\Python\Python38\lib\site-packages\moviepy\audio\AudioClip.py", line 7, in <module>
from moviepy.audio.io.ffmpeg_audiowriter import ffmpeg_audiowrite
File "C:\Users\Χρήστος\AppData\Local\Programs\Python\Python38\lib\site-packages\moviepy\audio\io\ffmpeg_audiowriter.py", line 7, in <module>
from moviepy.config import get_setting
File "C:\Users\Χρήστος\AppData\Local\Programs\Python\Python38\lib\site-packages\moviepy\config.py", line 36, in <module>
FFMPEG_BINARY = get_exe()
File "C:\Users\Χρήστος\AppData\Local\Programs\Python\Python38\lib\site-packages\imageio\plugins\ffmpeg.py", line 47, in get_exe
import imageio_ffmpeg
File "C:\Users\Χρήστος\AppData\Local\Programs\Python\Python38\lib\site-packages\imageio_ffmpeg\__init__.py", line 7, in <module>
from ._utils import get_ffmpeg_exe, get_ffmpeg_version
File "C:\Users\Χρήστος\AppData\Local\Programs\Python\Python38\lib\site-packages\imageio_ffmpeg\_utils.py", line 5, in <module>
from pkg_resources import resource_filename
File "C:\Users\Χρήστος\AppData\Local\Programs\Python\Python38\lib\site-packages\pkg_resources.py", line 1479, in <module>
register_loader_type(importlib_bootstrap.SourceFileLoader, DefaultProvider)
AttributeError: module 'importlib._bootstrap' has no attribute 'SourceFileLoader'

Uninstall moviepy with pip (pip uninstall moviepy)
Upgrade python (python -m ensurepip --upgrade)
Download whl file from: https://pypi.org/project/moviepy/#files
cd in the unzip downloaded folder and then
python setup.py build
python setup.py install
And everything is ok now!!!

Related

Is there any way to fix azure cli import pyparsing error on mac?

I'm trying to run azure CLI after reinstalling it I'm getting:
$ az
Traceback (most recent call last):
File "/usr/local/Cellar/python#3.8/3.8.11/Frameworks/Python.framework/Versions/3.8/lib/python3.8/runpy.py", line 185, in _run_module_as_main
mod_name, mod_spec, code = _get_module_details(mod_name, _Error)
File "/usr/local/Cellar/python#3.8/3.8.11/Frameworks/Python.framework/Versions/3.8/lib/python3.8/runpy.py", line 111, in _get_module_details
__import__(pkg_name)
File "/usr/local/Cellar/azure-cli/2.25.0/libexec/lib/python3.8/site-packages/azure/__init__.py", line 1, in <module>
__import__('pkg_resources').declare_namespace(__name__)
File "/usr/local/Cellar/azure-cli/2.25.0/libexec/lib/python3.8/site-packages/pkg_resources/__init__.py", line 78, in <module>
__import__('pkg_resources.extern.packaging.requirements')
File "/usr/local/Cellar/azure-cli/2.25.0/libexec/lib/python3.8/site-packages/pkg_resources/_vendor/packaging/requirements.py", line 9, in <module>
from pkg_resources.extern.pyparsing import stringStart, stringEnd, originalTextFor, ParseException
File "/usr/local/Cellar/azure-cli/2.25.0/libexec/lib/python3.8/site-packages/pkg_resources/extern/__init__.py", line 52, in create_module
return self.load_module(spec.name)
File "/usr/local/Cellar/azure-cli/2.25.0/libexec/lib/python3.8/site-packages/pkg_resources/extern/__init__.py", line 44, in load_module
raise ImportError(
ImportError: The 'pyparsing' package is required; normally this is bundled with this package so if you get this warning, consult the packager of your distribution.
I checked the python binary path and I saw I already have this package.
Found the issue.
One of the sub-packages that called in the pyparsing package was called to a local folder script that has the same name. and as a result the import faild.
$ /usr/local/Cellar/azure-cli/2.25.0/libexec/bin/python
Python 3.8.11 (default, Jun 29 2021, 03:08:07)
[Clang 12.0.5 (clang-1205.0.22.9)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import pyparsing
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/Cellar/azure-cli/2.25.0/libexec/lib/python3.8/site-packages/pyparsing.py", line 104, in <module>
import copy
File "/Users/shprayev/copy.py", line 4, in <module>
from pymongo import MongoClient
ModuleNotFoundError: No module named 'pymongo'
So pyparsing imports copy and I had copy.py in my path.
after rename the script it worked

Getting error when trying to import seaborn library (python)

I am on Windows 10 and using python 3.7 through the command prompt.
Whenever I try to import the seaborn library through the command prompt, I get the error:
C:\Python Stuff>python3
Python 3.7.6 (tags/v3.7.6:43364a7ae0, Dec 19 2019, 01:54:44) [MSC v.1916 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import seaborn
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\berre\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\LocalCache\local-packages\Python37\site-packages\seaborn\__init__.py", line 6, in <module>
from .rcmod import *
File "C:\Users\berre\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\LocalCache\local-packages\Python37\site-packages\seaborn\rcmod.py", line 5, in <module>
from . import palettes, _orig_rc_params
File "C:\Users\berre\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\LocalCache\local-packages\Python37\site-packages\seaborn\palettes.py", line 12, in <module>
from .utils import desaturate, set_hls_values, get_color_cycle
File "C:\Users\berre\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\LocalCache\local-packages\Python37\site-packages\seaborn\utils.py", line 7, in <module>
from scipy import stats
File "C:\Users\berre\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\LocalCache\local-packages\Python37\site-packages\scipy\stats\__init__.py", line 384, in <module>
from .stats import *
File "C:\Users\berre\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\LocalCache\local-packages\Python37\site-packages\scipy\stats\stats.py", line 179, in <module>
from scipy.spatial.distance import cdist
File "C:\Users\berre\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\LocalCache\local-packages\Python37\site-packages\scipy\spatial\__init__.py", line 99, in <module>
from .qhull import *
ImportError: DLL load failed: The specified module could not be found.
How do I deal with this error? I have tried uninstalling and reinstalling seaborn and its dependencies multiple times, along with using old versions of some of the libraries, but none of that seems to work.

pandas won't import despite trying many versions of python

I just ran python -m install pandas, but I can't import pandas:
C:\Users\Administrator>python
Python 3.6.0 (v3.6.0:41df79263a11, Dec 23 2016, 07:18:10) [MSC v.1900 32 bit (Intel)] 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 42, in <module>
from pandas.core.api import *
File "C:\Python36\lib\site-packages\pandas\core\api.py", line 10, in <module>
from pandas.core.groupby.groupby import Grouper
File "C:\Python36\lib\site-packages\pandas\core\groupby\__init__.py", line 2, in <module>
from pandas.core.groupby.groupby import (
File "C:\Python36\lib\site-packages\pandas\core\groupby\groupby.py", line 49, in <module>
from pandas.core.frame import DataFrame
File "C:\Python36\lib\site-packages\pandas\core\frame.py", line 74, in <module>
from pandas.core.series import Series
File "C:\Python36\lib\site-packages\pandas\core\series.py", line 3978, in <module>
Series._add_series_or_dataframe_operations()
File "C:\Python36\lib\site-packages\pandas\core\generic.py", line 8891, in _add_series_or_dataframe_operations
from pandas.core import window as rwindow
File "C:\Python36\lib\site-packages\pandas\core\window.py", line 36, in <module>
import pandas._libs.window as _window
ImportError: DLL load failed: The specified module could not be found.
I've tried various python versions(3.4, 3.5., 3.6, etc) and 32 vs 64 bit but with no luck. I'm running Python 3.6 on 32 bit now on windows.
I can see this file: window.cp36-win32.pyd inside the pandas _libs folder under my site-packages. What's wrong with it?
Pandas v0.23 was released on May 15, 2018 and there are still some issues of which yours is one. Except you absolutely have to use 0.23, try installing v0.22
pip install pandas==0.22
More info here: https://github.com/pandas-dev/pandas/issues/21106

Cannot import any module in python

Python libraries are giving error on importing them.Almost all library are giving same error. This is the case for simple pip module as well as pandas,etc.
1.Pip
$python
Python 2.7.12 (default, Nov 19 2016, 06:48:10)
[GCC 5.4.0 20160609] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import pip
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.7/dist-packages/pip/__init__.py", line 13, in <module>
from pip.exceptions import InstallationError, CommandError, PipError
File "/usr/lib/python2.7/dist-packages/pip/exceptions.py", line 6, in <module>
from pip._vendor.six import iteritems
File "/usr/lib/python2.7/dist-packages/pip/_vendor/__init__.py", line 64, in <module>
vendored("cachecontrol")
File "/usr/lib/python2.7/dist-packages/pip/_vendor/__init__.py", line 36, in vendored
__import__(modulename, globals(), locals(), level=0)
File "/usr/share/python-wheels/CacheControl-0.11.5-py2.py3-none-any.whl/cachecontrol/__init__.py", line 9, in <module>
File "/usr/share/python-wheels/CacheControl-0.11.5-py2.py3-none-any.whl/cachecontrol/wrapper.py", line 1, in <module>
File "/usr/share/python-wheels/CacheControl-0.11.5-py2.py3-none-any.whl/cachecontrol/adapter.py", line 3, in <module>
File "/usr/share/python-wheels/requests-2.9.1-py2.py3-none-any.whl/requests/__init__.py", line 53, in <module>
File "/usr/share/python-wheels/requests-2.9.1-py2.py3-none-any.whl/requests/packages/__init__.py", line 29, in <module>
File "/usr/share/python-wheels/urllib3-1.13.1-py2.py3-none-any.whl/urllib3/__init__.py", line 8, in <module>
File "/usr/share/python-wheels/urllib3-1.13.1-py2.py3-none-any.whl/urllib3/connectionpool.py", line 35, in <module>
File "/usr/share/python-wheels/urllib3-1.13.1-py2.py3-none-any.whl/urllib3/connection.py", line 14, in <module>
File "/usr/lib/python2.7/httplib.py", line 80, in <module>
import mimetools
File "/usr/lib/python2.7/mimetools.py", line 6, in <module>
import tempfile
File "/usr/lib/python2.7/tempfile.py", line 35, in <module>
from random import Random as _Random
File "random.py", line 2
hvsbiav
^
IndentationError: unexpected indent
Please help!!!
::::update:::::
I know this is not the ideal way but I tackled the problem by simply replacing random file from online then it worked fine.
Looking at the traceback, it seems that you have an incorrect indentation in your random.py file. Try looking at the original file and match your contents with it.
However, if the problem still persists you can try to force re-install a Python package using:
sudo pip install --upgrade --no-deps --force-reinstall <packagename>
Or, you could re-install Python 2.7 using:
sudo apt-get install --reinstall python2.7

Not able to install requests on cygwin - ImportError: No module named _io

When I try the following command
pip install requests
I am getting the following error
Traceback (most recent call last):
File "/usr/bin/pip", line 9, in <module>
load_entry_point('pip==1.4.1', 'console_scripts', 'pip')()
File "/usr/lib/python2.7/site-packages/pkg_resources.py", line 343, in load_entry_point
return get_distribution(dist).load_entry_point(group, name)
File "/usr/lib/python2.7/site-packages/pkg_resources.py", line 2307, in load_entry_point
return ep.load()
File "/usr/lib/python2.7/site-packages/pkg_resources.py", line 2013, in load
entry = __import__(self.module_name, globals(),globals(), ['__name__'])
File "/usr/lib/python2.7/site-packages/pip-1.4.1-py2.7.egg/pip/__init__.py", line 10, in <module>
from pip.util import get_installed_distributions, get_prog
File "/usr/lib/python2.7/site-packages/pip-1.4.1-py2.7.egg/pip/util.py", line 8, in <module>
import zipfile
File "/usr/lib/python2.7/zipfile.py", line 6, in <module>
import io
File "/usr/lib/python2.7/io.py", line 60, in <module>
import _io
ImportError: No module named _io
But when I tried to check the env using the following command
env python
I could see that it is running from python 2.7 only
Python 2.7.3 (default, Dec 18 2012, 13:50:09)
[GCC 4.5.3] on cygwin
Type "help", "copyright", "credits" or "license" for more information.
So in the interactive command line I tried the following
>>> import _io
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named _io
It is probably because your Anti-Virus program deleted io.py. I just had to reinstall python on cygwin and try installing the program with the Anti-Virus turned off. I successfully installed request this way.
Your pip has broken or conflict with two package installation easy_install vs pip.
1) upgrade or re install with easy_install pip
will solve the problem, if you have other issue with your virtual env due to 14.04 upgrade then look at the question here.similar stackoverflow question

Categories