Hola tengo este error (python): TypeError: ‘Image’ object does not support item assignment

tengo un error que no sé como solucionar: TypeError: ‘Image’ object does not support item assignment. Lo que hago es convertir un punto rgb a cmyk -> punto a un cuadrícula de 3*3 (la imagen resultante será más grande), estos puntos de la cuadrícula serán magenta, cyan, yellow, black en proporción a la cantidad de color que haya dado la conversión. No soy programador profesional, solo un gran aficionado interesado en la programación. Así que posiblemente este programa se podría mejorar totalmente, cualquier sugerencia se agradece.


from PIL import Image
from PIL import ImageColor
import cv2
import numpy as np
imagen = Image.open("tintin.jpg")#primero pasamos a RGB
rgb_imagen = imagen.convert('RGB')
width, height = rgb_imagen.size
imagen2 = Image.new("RGB", (width*3, height*3), (255,255,255,255))
matriz = ((0,0,0),(0,0,0),(0,0,0),(0,0,0),(0,0,0),(0,0,0),(0,0,0),(0,0,0),(0,0,0))
m = np.array(matriz)
y=1
while ( y<(height-1) ):
    x=1
    while ( x<(width-2)):
       r, g, b = rgb_imagen.getpixel((x, y)) 
       k = 1.0000001-(max(r,g,b)/255)
       cyan = (1-r/255-k)/(1-k)
       magenta = (1-g/255-k)/(1-k)
       yellow = (1-b/255-k)/(1-k)
       k1=100*round(k, 2)
       cyan1=100*round(cyan, 2)
       magenta1=100*round(magenta,2)
       yellow1=100*round(yellow,2)
       total= (k1+cyan1+magenta1+yellow1)+0.0000001
       k2= (k1/total)*100
       cyan2= (cyan1/total)*100
       magenta2= (magenta1/total)*100
       yellow2= (yellow1/total)*100
       k3=round(k2,0)
       cyan3=round(cyan2,0)
       magenta3=round(magenta2,0)
       yellow3=round(yellow2,0)
       k4=(int)(round((k3*9/100),0))
       cyan4=(int)(round((cyan3*9/100),0))
       magenta4=(int)(round((magenta3*9/100),0))
       yellow4=(int)(round((yellow3*9/100),0))
       print("cyan%=",cyan4,"magenta%=",magenta4,"yellow%=",yellow4,"negro=%",k4)
       i=0
       while (i!=9):
             if (cyan4!=0):
                m(i)= (0,255,255); cyan4=cyan4-1; i=i+1
             if (magenta4!=0):
                m(i)= (255,0,255); magenta4=magenta4-1; i=i+1
             if (yellow4!=0):
                m(i)= (255,255,0); yellow4=yellow4-1; i=i+1
             if (k4!=0):
                m(i)= (0,0,0); k4=k4-1; i=i+1 
       print (m)        

       imagen2(x-1, y-1)=  m(1)                                       
       imagen2(x, y-1)=  m(2) 
       imagen2(x+1, y-1)= m(3)  
       imagen2(x-1, y)=  m(4) 
       imagen2(x+1,y)= m(5)   
       imagen2(x, y)=  m(6) 
       imagen2(x-1, y+1)=  m(7)   
       imagen2(x, y+1)=  m(8) 
       imagen2(x+1, y+1)=  m(9)  
       x=x+1
    y=y+1    

imagen2.save("cmyk_aprox.gif") ````




python – TypeError: ‘DataFrame’ object is not callable?

from mlxtend.plotting import plot_pca_correlation_graph
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt

data_corr = pd.read_csv("type_1_teste.csv")

X, y = data_corr() #The columns represent the different variables and the lines are the following variables

X_norm = data_corr / data_corr.std(axis=0) # Normalizing the feature columns is recommended

feature_names = ('B1', 'N1', 'P1', 'L1', 'T1', 'U1')

matplotlib_figure, correlation_matrix = plot_pca_correlation_graph(X_norm, feature_names, dimensions=(1, 2)) 

plt.savefig('cc_type_1.png', format='png')
plt.show()

ion$ python correlation_circle.py
Traceback (most recent call last):
File “correlation_circle.py”, line 15, in
X, y = data_corr() #The columns represent the different variables and the lines are the following variables

TypeError: ‘DataFrame’ object is not callable

react.js – Unit test kidding https request with mocks gives typeError error: The & # 39; end & # 39; cannot be read from undefined

Hello, I have the following code

Function handler (…)
{
var req = https.request (options, function (res) {

});

req.on('error', function (e) {
    context.done(null, 'FAILURE');
    return callback(new Error(`Error: ${e.message}`));
});

if (writeContent) {
    req.write(writeContent);
}

req.end();

}}
Testing this function by one unit leads to an error in request and request
TypeError: The & # 39; end & # 39; property cannot be read from undefined
And also TypeError: The property & # 39; on & # 39; cannot be read from undefined

Please help how I can mock these calls.
Thank you so much!

How to fix "default.js: 70 Uncaught TypeError: property & # 39; method_code & # 39; cannot be read from zero" Magento 2 checkout page error

On the checkout page, the error "default.js: 70 Uncaught TypeError: property & # 39; method_code & # 39; cannot be read from zero" is displayed.
how to fix it?
or value of & # 39; method_code & # 39; receive?

Problems checking Firefox on Android Tab. The error cannot connect to the debug target. TypeError: This topWindow is null

I'm having trouble with Firefox to examine a tab in Firefox on Android. I get this error message when I try to check a tab in about: debugging

Error cannot connect to the debug target. See error details below:

TypeError: this topWindow is null

python – TypeError: The view function did not return a valid response. The function either returned None or ended without a return statement

Please let me know where I do not include the returns. Or is the problem somewhere else? I use Python 3.6 and Flask. I'm trying to make a bot. The bot works well on the terminal. Now I'm trying to give it a user interface and use Flask.

def chat(user_input):
    print("Start talking with the bot !! Press q to quit ")
    print("You :"+user_input)
    while True:
        #inp=input("You: ")
        if user_input.lower() == "q":
            break

        results = model.predict((bag_of_words(user_input, words)))
        arr_result = results(0)
        print(arr_result)

        # gives index of the greatest number
        results_index = np.argmax(results)
        print('The result_index is '+str(results_index))

        # gives the relevant tag
        tag = labels(results_index)
        print('The tag is ' + tag)
        print('labels are'+str(labels))

        if arr_result(results_index) > 0.6:
            print('arr_result(results_index)>0.6 ' +
                  str(arr_result(results_index)))
            # get a random response from the json file
            for tg in data("intents"):
                print(tg)
                if tg('tag') == tag:
                    response = tg('responses')
                    print('the array of response is' + str(response))
                    rand_response = random.choice(response)

                    bot_response = str(rand_response)
                    print("Bot: "+bot_response)
                    return render_template('index.html', user_input=user_input, bot_response=bot_response)
                else:
                    print("Tag not found "+bot_response)
                    return render_template('index.html', user_input=user_input, bot_response="Sorry, I do not understand")

        else:
            bot_response = "Sorry, I do not understand"
            print("Bot: "+bot_response)
            return render_template('index.html', user_input=user_input, bot_response=bot_response)

I always get the following error …

127.0.0.1 - - (08/Mar/2020 02:40:27) "(35m(1mPOST /process HTTP/1.1(0m" 500 -
Traceback (most recent call last):
  File "C:UsersKuldeepAppDataLocalProgramsPythonPython36libsite-packagesflaskapp.py", line 2463, in __call__
    return self.wsgi_app(environ, start_response)
  File "C:UsersKuldeepAppDataLocalProgramsPythonPython36libsite-packagesflaskapp.py", line 2449, in wsgi_app
    response = self.handle_exception(e)
  File "C:UsersKuldeepAppDataLocalProgramsPythonPython36libsite-packagesflaskapp.py", line 1866, in handle_exception
    reraise(exc_type, exc_value, tb)
  File "C:UsersKuldeepAppDataLocalProgramsPythonPython36libsite-packagesflask_compat.py", line 39, in reraise
    raise value
  File "C:UsersKuldeepAppDataLocalProgramsPythonPython36libsite-packagesflaskapp.py", line 2446, in wsgi_app
    response = self.full_dispatch_request()
  File "C:UsersKuldeepAppDataLocalProgramsPythonPython36libsite-packagesflaskapp.py", line 1952, in full_dispatch_request
    return self.finalize_request(rv)
  File "C:UsersKuldeepAppDataLocalProgramsPythonPython36libsite-packagesflaskapp.py", line 1967, in finalize_request
    response = self.make_response(rv)
  File "C:UsersKuldeepAppDataLocalProgramsPythonPython36libsite-packagesflaskapp.py", line 2097, in make_response
    "The view function did not return a valid response. The"
TypeError: The view function did not return a valid response. The function either returned None or ended without a return statement.
127.0.0.1 - - (08/Mar/2020 02:40:27) "(37mGET /process?__debugger__=yes&cmd=resource&f=style.css HTTP/1.1(0m" 200 -
127.0.0.1 - - (08/Mar/2020 02:40:27) "(37mGET /process?__debugger__=yes&cmd=resource&f=jquery.js HTTP/1.1(0m" 200 -
127.0.0.1 - - (08/Mar/2020 02:40:27) "(37mGET /process?__debugger__=yes&cmd=resource&f=debugger.js HTTP/1.1(0m" 200 -
127.0.0.1 - - (08/Mar/2020 02:40:27) "(37mGET /process?__debugger__=yes&cmd=resource&f=console.png HTTP/1.1(0m" 200 -
127.0.0.1 - - (08/Mar/2020 02:40:27) "(37mGET /process?__debugger__=yes&cmd=resource&f=ubuntu.ttf HTTP/1.1(0m" 200 -

Angle – ERROR TypeError: jQuery (…). metismenu is not a function

I have a problem with jQuery in an Angular9 project. This is shown in the console:

ERROR TypeError: jQuery (…). Metismsu is not a function
at NavigationComponent.ngAfterViewInit (navigation.component.ts: 16)
at callHook (core.js: 3937)
at callHooks (core.js: 3901)
at executeInitAndCheckHooks (core.js: 3842)
at refreshView (core.js: 11853)
at refreshDynamicEmbeddedViews (core.js: 13142)
at refreshView (core.js: 11800)
at refreshComponent (core.js: 13217)
at refreshChildComponents (core.js: 11508)
at refreshView (core.js: 11829)
Enter the image description here
I've checked several forums and can't find a solution. I exported the query from assets, but I also installed it in my modules because I had to use a template.

python – TypeError: __init __ () 2 required position arguments are missing

I have a Keras model in format .h5, I want to read it with this code:

#model.h5 is name of mode, tf and modellib is read

custom_objects={'tf': tf,'BatchNorm':modellib.BatchNorm,'ProposalLayer':
                modellib.ProposalLayer} 
model=tf.keras.models.load_model("model.h5")

But I get an error

TypeError: init () 2 required position arguments are missing: & # 39; comment_count & # 39; and & # 39; nms_threshold & # 39;

I have the latest version of TensorFlow (2.2). Changing the version of TensorFlow does not help.

Javascript – TypeError not caught: $ is not a function

function inserir_registo()
{

    //dados a enviar, vai buscar os valores dos campos que queremos enviar para a BD

var areas = ();
$("(name='areas()'):checked").each(function(i,e){
   areas.push(e.value)
});

var sexo = $("input(name='sexo'):checked").val();

var habilitacoes = $("input(name='habilitacoes'):checked").val();
if (habilitacoes == "outro"){
    habilitacoes = "outro - " + $("#que_outro").val();
}

var sexta = $("input(name='sexta'):checked").val();
if (sexta == "outro horário"){
    sexta = "outro - " + $("#que_outro_sexta").val();
}

var sabado = $("input(name='sabado'):checked").val();
if (sabado == "outro horário"){
    sabado = "outro - " + $("#que_outro_sabado").val();
}

var domingo = $("input(name='domingo'):checked").val();
if (domingo == "outro horário"){
    domingo = "outro - " + $("#que_outro_domingo").val();
}

var voluntarioAPPACDM = $("input(name='voluntarioAPPACDM'):checked").val();
var emprestimoTraje = $("input(name='emprestimoTraje'):checked").val();


   var dadosajax = {
        'nome' : $("#nome").val(),
        'apelido' : $("#apelido").val(),
        'sexo' : sexo,
        'idade' : $("#idade").val(),
        'morada' : $("#morada").val(),
        'contacto' : $("#contacto").val(),
        'email' : $("#email").val(),
        'habilitacoes' : habilitacoes,
        'areas' : areas,
        'sexta' : sexta,
        'sabado' : sabado,
        'domingo' : domingo,
        'voluntarioAPPACDM' : voluntarioAPPACDM,
        'emprestimoTraje' : emprestimoTraje,
        'observacoes' : $("#observacoes").val()
    };
    pageurl = '/formularios-inscricao/voluntarios/rodaVoluntarios.php';
    //para consultar mais opcoes possiveis numa chamada ajax
    //http://api.jquery.com/jQuery.ajax/
    $.ajax({
	
        //url da pagina
        url: pageurl,
        //parametros a passar
        data: dadosajax,
        //tipo: POST ou GET
        type: 'POST',
        //cache
        beforeSend: function () {
        //Aqui adicionas o loader
       $.blockUI({ message: $("#divCorpo") });
    },   
        cache: false,
        //se ocorrer um erro na chamada ajax, retorna este alerta
        //possiveis erros: pagina nao existe, erro de codigo na pagina, falha de comunicacao/internet, etc etc etc
        error: function(){
            alert('Erro: Inserir Registo!!');
        },
        //retorna o resultado da pagina para onde enviamos os dados
        success: function(result)
        { 
            $.unblockUI();
            //se foi inserido com sucesso
            if($.trim(result) == '1')
            {
                swal({
                    title: 'Inscrição submetida!',
                    text: $("#nome").val() + ", a sua inscrição foi submetida com sucesso. Dentro de instantes, receberá um e-mail com algumas indicações que deverão ser tomadas em consideração.",
                    type: 'success',
                    showCancelButton: false,
                    confirmButtonColor: '#3085d6',
                    confirmButtonText: 'OK'
                }).then((result) => {
                    if (result.value) {
                        setTimeout('location.reload();', 1000);
                    }
                })
            }
            //se foi um erro
            else if ($.trim(result) == '2')
            {
                swal({
                    type: 'error',
                    title: 'Submissão repetida',
                    text: 'Já existe uma submissão com os dados que introduziu. Se acredita que está a visualizar esta mensagem por engano, por favor, entre em contacto com a organização do Festival Romano - Talabrigae Ex Libris.'
                })
            }
            else
            {
                alert("Ocorreu um erro ao inserir o seu registo!");
            }

        }
    });
}