Python 3 – die besten Beiträge

TypeError: can only concatenate str (not "function") to str?

ich möchte eine ui für mailtm erstellen aber bekomme kein output raus also wenn email ankommen werden sie nicht angezeigt und wenn ich listener eingebe bekomme ich jedes mal den gleichen fehler code

Fehler code:

TypeError: can only concatenate str (not "function") to str

from mailtm import *


def listener(message):
    print("\nSubject: " + message['subject'] + str(listener))
    print("Content: " + message['text'] if message['text'] else message['html'] + str(listener))


test = Email()
print("\nDomain: " + test.domain)

test.register()
print("\nEmail Adress: " + str(test.address))


test.start(listener, interval=3)
print("\nHab Sabr.....")


main = ctk.CTk()
main.geometry("500x320")
main.title("Temp mail By Amjn")


emaila = ctk.CTkEntry(main, placeholder_text="         " + test.address, width=900, font=("Helvetica", 20))
emaila.configure(state="readonly")
emaila._corner_radius = 10
emaila.pack()


Copyt = ctk.CTkLabel(main, text="Copy Email", font=("Helvetica", 20))
Copyt.pack()


def neuw(self=None):
    neu = ctk.CTkToplevel(main)
    neu.title("Emails              (MADE BY AMJN)")
    neu.geometry("500x320")
    neu.corner_radius = 30
    neu.resizable(width=True, height=True)

    Ausg = ctk.CTkEntry(neuw, placeholder_text=("         ") + listener, width=900, font=("Helvetica", 20))
    Ausg.pack()


knopf = ctk.CTkButton(main, text="Emails", font=("Helvetica", 20), command=neuw)
knopf.pack(pady=20)

main.mainloop()
Code, Programmiersprache, Python, UI, Python 3, Tkinter, Pycharm

SSL-Paket kann nicht installiert werden. Kann mir jemand das Problem erklären?


Servus alle zusammen.

Ich habe mal wieder eins der unnötigsten Probleme die man so gar nicht gebrauchen kann.
Vorab: Ich verwende PyCharm CommunityEdit2023

Folgende Problematik stellt sich mir:Ich versuche über den PyCharm Interpreter das Paket ssl zu laden und erhalte:

Collecting ssl

 Using cached ssl-1.16.tar.gz (33 kB)

 Using cached ssl-1.15.tar.gz (32 kB)




  ERROR: Command errored out with exit status 1:

   command: 'D:\Python\python.exe' -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\Paddy\\AppData\\Local\\Temp\\pip-install-6xunn48y\\ssl_93be5a3dfd464eefb55e12eacc1c7aae\\setup.py'"'"'; __file__='"'"'C:\\Users\\Paddy\\AppData\\Local\\Temp\\pip-install-6xunn48y\\ssl_93be5a3dfd464eefb55e12eacc1c7aae\\setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base 'C:\Users\Paddy\AppData\Local\Temp\pip-pip-egg-info-xz6xi0b2'

     cwd: C:\Users\Paddy\AppData\Local\Temp\pip-install-6xunn48y\ssl_93be5a3dfd464eefb55e12eacc1c7aae\

  Complete output (6 lines):

  Traceback (most recent call last):

   File "<string>", line 1, in <module>

   File "C:\Users\Paddy\AppData\Local\Temp\pip-install-6xunn48y\ssl_93be5a3dfd464eefb55e12eacc1c7aae\setup.py", line 33

    print 'looking for', f

       ^

  SyntaxError: Missing parentheses in call to 'print'. Did you mean print('looking for', f)?

  ----------------------------------------

WARNING: Discarding https://files.pythonhosted.org/packages/83/21/f469c9923235f8c36d5fd5334ed11e2681abad7e0032c5aba964dcaf9bbb/ssl-1.16.tar.gz#sha256=ac21156fee6aee9eb8d765bbb16f5f49492d81ff4b22f7b8fc001d2251120930 (from https://pypi.org/simple/ssl/). Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.

  ERROR: Command errored out with exit status 1:

   command: 'D:\Python\python.exe' -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\Paddy\\AppData\\Local\\Temp\\pip-install-6xunn48y\\ssl_0d4afefa00504f218b834c3475a8235c\\setup.py'"'"'; __file__='"'"'C:\\Users\\Paddy\\AppData\\Local\\Temp\\pip-install-6xunn48y\\ssl_0d4afefa00504f218b834c3475a8235c\\setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base 'C:\Users\Paddy\AppData\Local\Temp\pip-pip-egg-info-2f8p2rk1'

     cwd: C:\Users\Paddy\AppData\Local\Temp\pip-install-6xunn48y\ssl_0d4afefa00504f218b834c3475a8235c\

  Complete output (6 lines):

  Traceback (most recent call last):

   File "<string>", line 1, in <module>

   File "C:\Users\Paddy\AppData\Local\Temp\pip-install-6xunn48y\ssl_0d4afefa00504f218b834c3475a8235c\setup.py", line 74

    print 'looking for', f

       ^

  SyntaxError: Missing parentheses in call to 'print'. Did you mean print('looking for', f)?

  ----------------------------------------

WARNING: Discarding https://files.pythonhosted.org/packages/3a/c2/846a19d1572ec6cb8ac438d58a898de8926d32e13f0355cdf4ab00864b5f/ssl-1.15.tar.gz#sha256=1266302ce62c4b60c7ca0e1d3d104ba11d2749e5881d8ac4f006cf9a0446d589 (from https://pypi.org/simple/ssl/). Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.

ERROR: Could not find a version that satisfies the requirement ssl (from versions: 1.15, 1.16)

ERROR: No matching distribution found for ssl

WARNING: You are using pip version 21.1.3; however, version 24.0 is available.

You should consider upgrading via the 'D:\Python\python.exe -m pip install --upgrade pip' command.

Via cmd erhalte ich die gleiche Meldung.
Ich habe alle Python-Versionen schon deinstalliert, System neu gestartet und wieder installiert. Das gleiche habe ich auch mit pip probiert.

Kann mir hier vielleicht jemand weiterhelfen?

Vielen Dank und liebe Grüße im Voraus! :)

cmd, Code, Error, Python, SSL, pip, Python 3, Windows 10, Pycharm

Turtle-Grafik in Python - letzter Aufruf wird nicht angezeigt?

Hallo Community, eine Frage:

Ich habe versucht, die grafische Simulation einer Ampel zu coden. Die Darstellung soll der Einfachkeit halber mit Turtle funktionieren. Im Grunde klappt alles wunderbar, nur die Grün-Phase wird in der Anzeige "übersprungen". Spannend: Wenn ich manuell über die passenden Methode die Grünphase einstelle, wird sie einwandfrei angezeigt. Nur in der Endlosschleife sehe ich gar nichts bzw. ein kurzes "Flackern".

Hat jemand eine Idee, woran das liegen könnten?

import turtle
import time


class Lampe():
    def __init__(self, farbe, x, y):
        self.__zustand = False
        self.farbe = farbe
        self.turtle = turtle.Turtle()
        self.turtle.hideturtle()
        self.turtle.penup()
        self.turtle.speed(0)
        self.turtle.shape("circle")
        self.turtle.color(farbe)
        self.turtle.goto(x, y)


    def einschalten(self):
        self.__zustand = True
        self.turtle.color(self.farbe)
        self.turtle.stamp()


    def ausschalten(self):
        self.__zustand = False
        self.turtle.clear()


    def zustand(self):
        return self.__zustand


class Ampel():
    def __init__(self):
        self.__rot = Lampe("red", 0, 50)
        self.__gelb = Lampe("yellow", 0, 0)
        self.__green = Lampe("green", 0, -50)
        self.__phase = "rot"
        self.__rot.einschalten()
        
    def phase_rot(self):
        self.__rot.einschalten()
        self.__gelb.ausschalten()
        self.__green.ausschalten()
        self.__phase = "rot"
        
    def phase_gelb(self):
        self.__rot.ausschalten()
        self.__gelb.einschalten()
        self.__green.ausschalten()
        self.__phase = "gelb"
        
    def phase_green(self):
        self.__rot.ausschalten()
        self.__gelb.ausschalten()
        self.__green.einschalten()
        self.__phase = "green"
        
    def phase_rotgelb(self):
        self.__rot.einschalten()
        self.__gelb.einschalten()
        self.__green.ausschalten()
        self.__phase = "rotgelb"


    def umschalten(self):
        if self.__phase == "rot":
            self.phase_rotgelb()
        elif self.__phase == "rotgelb":
            self.phase_green()
        elif self.__phase == "green":
            self.phase_gelb()
        elif self.__phase == "gelb":
            self.phase_rot()
        else:
            print("Something went horribly utterly wrong. Doomsday!")
        time.sleep(2)
        self.umschalten()


if __name__ == "__main__":
    turtle.Screen().bgcolor("black")
    ampel = Ampel()
    ampel.umschalten()


Python, Python 3

Meistgelesene Beiträge zum Thema Python 3