I am trying to run the following code:
from moviepy.editor import *
videoclip = VideoFileClip("filename.mp4")
audioclip = AudioFileClip("audioname.mp3")
new_audioclip = CompositeAudioClip([videoclip.audio, audioclip])
videoclip.audio = new_audioclip
videoclip.write_videofile("new_filename.mp4")
but when I run it I got the following error:
*
Traceback (most recent call last): File "C:/Users/arthu/PycharmProjects/Comprei da China/video.py", line 5, in
new_audioclip = CompositeAudioClip([videoclip.audio, audioclip]) File "C:\Users\arthu\PycharmProjects\Comprei da China\venv\lib\site-packages\moviepy\audio\AudioClip.py", line 285, in
init
ends = [c.end for c in self.clips] File "C:\Users\arthu\PycharmProjects\Comprei da China\venv\lib\site-packages\moviepy\audio\AudioClip.py", line 285, in
ends = [c.end for c in self.clips] AttributeError: 'NoneType' object has no attribute 'end'
*
Does anybody know how can I solve that?
Pass only one parameter in CompositeAudioClip the built in class AudioClip.py has one parameter
from moviepy.editor import *
videoclip = VideoFileClip("filename.mp4")
audioclip = AudioFileClip("audioname.mp3")
new_audioclip = CompositeAudioClip([audioclip])
videoclip.audio = new_audioclip
videoclip.write_videofile("new_filename.mp4")
Related
To begin with, I have followed up the instruction of the installation guide and deploy the new virtual environment with the yml file presented over that page, but I still met with the same problem as I executed the following codes. I have tried out many ways to solve the problem, please assist me to solve the problem.
Plus, I have referred to the issues on the official pymc3 website, but the problem still existed.
The reproducible example:
import pymc3 as pm
import numpy as np
import pandas as pd
import scipy.stats as stats
from datetime import datetime
import theano.tensor as T
early = 10
late = 12
y = np.r_[np.random.poisson(early, 25), np.random.poisson(late, 75)]
niter = 10000
t = range(len(y))
with pm.Model() as change_point:
cp = pm.DiscreteUniform('change_point', lower=0, upper=len(y), testval=len(y)//2)
mu0 = pm.Exponential('mu0', 1/y.mean())
mu1 = pm.Exponential('mu1', 1/y.mean())
mu = T.switch(t < cp, mu0, mu1)
Y_obs = pm.Poisson('Y_obs', mu=mu, observed=y)
trace = pm.sample(niter)
pm.traceplot(trace, varnames=['change_point', 'mu0', 'mu1'])
Here is the error reports:
[You can find the C code in this temporary file: C:\Users\Mick\AppData\Local\Temp\theano_compilation_error_xk8zcr1g
Traceback (most recent call last):
File "C:\....py", line 48, in <module>
mu = T.switch(t < cp, mu0, mu1)
File "C:\...\lib\site-packages\theano\tensor\var.py", line 41, in __gt__
rval = theano.tensor.basic.gt(self, other)
File "C:\...\lib\site-packages\theano\graph\op.py", line 253, in __call__
compute_test_value(node)
File "C:\...\lib\site-packages\theano\graph\op.py", line 126, in compute_test_value
thunk = node.op.make_thunk(node, storage_map, compute_map, no_recycling=[])
File "C:\...\lib\site-packages\theano\graph\op.py", line 634, in make_thunk
return self.make_c_thunk(node, storage_map, compute_map, no_recycling)
File "C:\...\lib\site-packages\theano\graph\op.py", line 600, in make_c_thunk
outputs = cl.make_thunk(
File "C:\...\lib\site-packages\theano\link\c\basic.py", line 1203, in make_thunk
cthunk, module, in_storage, out_storage, error_storage = self.__compile__(
File "C:\...\lib\site-packages\theano\link\c\basic.py", line 1138, in __compile__
thunk, module = self.cthunk_factory(
File "C:\...\lib\site-packages\theano\link\c\basic.py", line 1634, in cthunk_factory
module = get_module_cache().module_from_key(key=key, lnk=self)
File "C:\...\lib\site-packages\theano\link\c\cmodule.py", line 1191, in module_from_key
module = lnk.compile_cmodule(location)
File "C:\...\lib\site-packages\theano\link\c\basic.py", line 1543, in compile_cmodule
module = c_compiler.compile_str(
File "C:\...\lib\site-packages\theano\link\c\cmodule.py", line 2546, in compile_str
raise Exception(
Exception: ('Compilation failed (return status=1): C:\\...\\AppData\\Local\\Temp\\ccujaONv.s: Assembler messages:\r. C:\\...\\AppData\\Local\\Temp\\ccujaONv.s:89: Error: invalid register for .seh_savexmm\r. ', 'FunctionGraph(Elemwise{gt,no_inplace}(<TensorType(int64, (True,))>, TensorConstant{[ 0 1 2 .. 97 98 99]}))')]
So, I need to resize an image in tkinter. Before you do anything - this is not a duplicate. I have gone through every other question on this site and none have helped me. The thing with me is - I don't wan't to save the image. I need to load the image, resize it, then display it with PhotoImage in a label. I tried to use ImageTk, but for some reason it won't work.
Here's my code with ImageTk:
from tkinter import *
import PIL
from PIL import Image, ImageTk
root = Tk()
left_nose_path_white = Image.open(r'C:\Users\User\Documents\Python stuff\Other apps\Veteris\Dog photos\Advanced\Sides\GIF\Nose\Nose (left) - White.gif')
def resize_image():
global left_nose_path_white
total_screen_width = root.winfo_screenwidth()
total_screen_height = root.winfo_screenheight()
frame_width, frame_height = left_nose_path_white.size
dog_new_width = int(frame_width / 3)
dog_new_height = int(frame_height / 3)
left_nose_path_white = left_nose_path_white.resize((dog_new_width, dog_new_height), Image.LANCZOS)
resize_image()
left_nose_img_white = ImageTk.PhotoImage(file = left_nose_path_white)
label = Label(image = left_nose_img_white)
label.pack()
root.mainloop()
This returns the error:
File "C:\Users\User\AppData\Local\Programs\Python\Python37\lib\site-packages\PIL\ImageTk.py", line 124, in __del__
name = self.__photo.name
AttributeError: 'PhotoImage' object has no attribute '_PhotoImage__photo'
My code should find the width and height of the original image, divide it by 3, and then show it. The reason I don't want to have to save the image is because the user will open the application several times.
I'm new to using PILL/Pillow, so the answer may be obvious.
I have Pillow installed using pip.
I only have one version of Python on my computer (Python 3.7)
Full Error:
Traceback (most recent call last):
File "C:\Users\User\Documents\Python stuff\Other apps\Veteris\Scripts\Veteris_program.py", line 230, in <module>
left_nose_img_white = ImageTk.PhotoImage(file = left_nose_path_white)
File "C:\Users\User\AppData\Local\Programs\Python\Python37\lib\site-packages\PIL\ImageTk.py", line 95, in __init__
image = _get_image_from_kw(kw)
File "C:\Users\User\AppData\Local\Programs\Python\Python37\lib\site-packages\PIL\ImageTk.py", line 64, in _get_image_from_kw
return Image.open(source)
File "C:\Users\User\AppData\Local\Programs\Python\Python37\lib\site-packages\PIL\Image.py", line 2779, in open
prefix = fp.read(16)
AttributeError: 'Image' object has no attribute 'read'
Exception ignored in: <function PhotoImage.__del__ at 0x000002B0A8A49950>
Traceback (most recent call last):
File "C:\Users\User\AppData\Local\Programs\Python\Python37\lib\site-packages\PIL\ImageTk.py", line 124, in __del__
name = self.__photo.name
AttributeError: 'PhotoImage' object has no attribute '_PhotoImage__photo'
Thanks for the help!
I am using astroplan to set up some astronomical observations. Previously, when I ran my code using Python 2.7, it plotted the target on the sky properly. Now, I have moved to Python 3.7 and I get an AttributError on the same code.
I took my larger code and stripped out everything that did not seem to trigger the error. Here below is code that will generate the complaint.
from astroplan import Observer, FixedTarget
import astropy.units as u
from astropy.time import Time
import matplotlib.pyplot as plt
from astroplan.plots import plot_sky
import numpy as np
time = Time('2015-06-16 12:00:00')
subaru = Observer.at_site('subaru')
vega = FixedTarget.from_name('Vega')
sunset_tonight = subaru.sun_set_time(time, which='nearest')
vega_rise = subaru.target_rise_time(time, vega) + 5*u.minute
start = np.max([sunset_tonight, vega_rise])
plot_sky(vega, subaru, start)
plt.show()
Expected result was a simple plot of the target, in this case, the star Vega, on the sky as seen by the Subaru telescope in Hawaii. The astroplan docs give a tutorial that shows how it was to look at the very end of this page:
https://astroplan.readthedocs.io/en/latest/tutorials/summer_triangle.html
Instead, I now get the following error:
Traceback (most recent call last):
File "plot_sky.py", line 16, in <module>
plot_sky(vega, subaru, start)
File "/usr1/local/anaconda_py3/ana37/lib/python3.7/site-packages/astropy/utils/decorators.py", line 842, in plot_sky
func = make_function_with_signature(func, name=name, **wrapped_args)
File "/usr1/local/anaconda_py3/ana37/lib/python3.7/site-packages/astropy/units/decorators.py", line 222, in wrapper
return_ = wrapped_function(*func_args, **func_kwargs)
File "/local/data/fugussd/rkbarry/.local/lib/python3.7/site-packages/astroplan/plots/sky.py", line 216, in plot_sky
ax.set_thetagrids(range(0, 360, 45), theta_labels, frac=1.2)
File "/usr1/local/anaconda_py3/ana37/lib/python3.7/site-packages/matplotlib/projections/polar.py", line 1268, in set_thetagrids
t.update(kwargs)
File "/usr1/local/anaconda_py3/ana37/lib/python3.7/site-packages/matplotlib/text.py", line 187, in update
super().update(kwargs)
File "/usr1/local/anaconda_py3/ana37/lib/python3.7/site-packages/matplotlib/artist.py", line 916, in update
ret = [_update_property(self, k, v) for k, v in props.items()]
File "/usr1/local/anaconda_py3/ana37/lib/python3.7/site-packages/matplotlib/artist.py", line 916, in <listcomp>
ret = [_update_property(self, k, v) for k, v in props.items()]
File "/usr1/local/anaconda_py3/ana37/lib/python3.7/site-packages/matplotlib/artist.py", line 912, in _update_property
raise AttributeError('Unknown property %s' % k)
AttributeError: Unknown property frac
I am implementing the code
import sys
sys.path.append('/home/stepfourward/naivebayes/Naive-Bayes/')
from NaiveBayes import *
import os
DClasses = ["python", "java", "hadoop", "django", "datascience", "php"]
base = "learn/"
p = Pool()
for i in DClasses:
p.learn(base + i, i)
NaiveBayes module contains Pool.py that has the function learn():
def learn(self, directory, dclass_name):
"""
directory is a path, where the files of the class with the name dclass_name can be found
"""
x = DocumentClass(self.__vocabulary)
dir = os.listdir(directory)
for file in dir:
d = Document(self.__vocabulary)
print(directory + "/" + file)
d.read_document(directory + "/" + file, learn=True)
x = x + d
self.__document_classes[dclass_name] = x
x.SetNumberOfDocs(len(dir))
but when I am applying the method p.learn(base + i, i) metioned in code above I am getting attribute error.
AttributeError: 'Pool' object has no attribute 'learn'
How to eradicate this error. Thanks.
Here are the correct steps to use the said NaiveBayes library, after you have cloned the repo as explained elsewhere in a folder Naive-Bayes:
What you do
import sys
sys.path.append('Naive-Bayes/') # your own path here
from NaiveBayes import * # NO error here
p = Pool()
produces an error:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'Pool' is not defined
What you should do:
import sys
sys.path.append('Naive-Bayes/')
from NaiveBayes.Pool import Pool # correct import
p = Pool() # runs OK now
DClasses = ["python", "java", "hadoop", "django", "datascience", "php"]
base = "learn/"
for i in DClasses:
p.learn(base + i, i)
At this point (but not before), I am getting an expected error, simply because your directories (e.g. learn/python) are not present in my machine:
Traceback (most recent call last):
File "<stdin>", line 2, in <module>
File "/home/herc/SO/Naive-Bayes/NaiveBayes/Pool.py", line 29, in learn
dir = os.listdir(directory)
FileNotFoundError: [Errno 2] No such file or directory: 'learn/python'
but the clear message is that the Pool object and the learn method in Pool.py can indeed be accessed.
Tested with Python 3.4.3 in Ubuntu...
I get this error when I run the code below:
'builtin_function_or_method' object is not iterable
I have searched stackoverflow, but cant find a answer to my question... Please help me!
def file2matrix(filename):
fr = open(filename)
arrayOLines = fr.readlines()
numberOfLines = len(arrayOLines)
returnMat = zeros((numberOfLines, 3))
classLabelVector = []
index = 0
for line in arrayOLines:
line = line.strip()
listFromLine = line.split('\t')
returnMat[index, :] = listFromLine[0:3]
classLabelVector.append(int(listFromLine[-1]))
index += 1
return returnMat, classLabelVector
and this is result...
>>> datingDataMat,datingLabels = kNN.file2matrix("datingTestSet.txt")
Traceback (most recent call last):
File "<input>", line 1, in <module>
File "C:\Users\Dennis Yang\PycharmProjects\mlaction\kNN.py", line 28, in file2matrix
for line in arrayOLines:
TypeError: 'builtin_function_or_method' object is not iterable