Python 3 – die besten Beiträge

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

Warum kann ich meinen HTML- Code nicht mit meinem Python- Code verbinden?

Hallo,

ich wollte meinen Python- Code mit meinem HTML- Code verbinden, damit, wenn mein Wake- Word "Luna" erkannt wurde, ein div in der Datei index.html seine Farbe ändert. Hier ist der Code:

Python:

from flask import Flask, render_template
from flask_socketio import SocketIO, emit

app = Flask(__name__)
app.config['SECRET_KEY'] = 'luna_secret1984773249523'
socketio = SocketIO(app)


@socketio.on('connect')
def handle_connect():
    emit('message', {'data': 'Connected'})


@socketio.on('start_listening')
def start_listening():
    if detect_wake_word():
        emit('color_change', {'color': 'red'})


@app.route('/')
def index():
    return render_template('output.html')

HTML /CSS:

... #color_div {
    width: 100%;
    height: 100%;
    position: absolute;
    background-color: green;
}    
</style>
</head>
<body>
<div id="color_div"></div>

JavaScript:

... // FLASK
        var socket = io();

        socket.on('connect', function() {
            socket.emit('start_listening');
        });

        socket.on('color_change', function(msg) {
            document.getElementById('color_div').style.backgroundColor = msg.color;
        });
</script>
</body>
</html>
    """
    with open("output.html", "w") as html_file:
        html_file.write(html_content)

    return "output.html"

Wenn ich den Code aber ausführe und "Luna" sage, ändert der Div nicht seine Farbe. Woran liegt das?

Freundliche Grüsse

HTML, Webseite, CSS, JavaScript, HTML5, Code, Programmiersprache, Python, Webentwicklung, Frontend, Python 3, Flask

Wie sende ich DNS Cookies mit dnslib?

Ich möchte mit dnslib die DNS-Antworten von den jeweiligen Anfragen mit einem DNS-Cookie versehen. Ich habe auch bereits etwas dafür in meinen Code implementiert, jedoch funktioniert das noch nicht so. Kann mir jemand sagen, was ich da brauche?

Der Code:

import socket
from dnslib import *

DNS_PORT = 53

dns_socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
dns_socket.bind(('', DNS_PORT))

print(f"DNS-Server hört auf Port {DNS_PORT}...")

def dns_forward(domain):
    try:
        ip_address = socket.gethostbyname(domain)
        return ip_address
    except socket.error:
        return '185.199.111.153' #Error 404

while True:
    data, address = dns_socket.recvfrom(1024)

    dns_message = DNSRecord.parse(data)
    dns_request = str(dns_message.q.qname)
    
    dns_answer = dns_forward(dns_request)
    
    client_ip = address[0]
    client_port = address[1]

    dns_cookie = ("4096")

    if client_ip == '192.168.0.113'
        dns_response = DNSRecord(DNSHeader(id=dns_message.header.id, qr=1, aa=1, ra=1), q=dns_message.q)
        dns_response.add_answer(RR(dns_request, QTYPE.A, rdata=A(dns_answer)))
        dns_response.add_ar(RR(dns_request, QTYPE.OPT, rdata=TXT(dns_cookie)))
        dns_socket.sendto(dns_response.pack(), address)
    
    print(f"DNS-Anfrage von {client_ip} mit Port {client_port} für {dns_request} die Antwort ist {dns_answer}")

Die Fehlermeldung:

Traceback (most recent call last):
 File "c:\Users\Stoppersocke\Documents\Projects\MDM Bypass\test5.py", line 35, in <module>
  dns_socket.sendto(dns_response.pack(), address)
           ^^^^^^^^^^^^^^^^^^^
 File "C:\Users\Stoppersocke\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\dnslib\dns.py", line 339, in pack
  ar.pack(buffer)
 File "C:\Users\Stoppersocke\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\dnslib\dns.py", line 885, in pack
  for opt in self.rdata:
TypeError: 'TXT' object is not iterable
DNS, Netzwerktechnik, Programmiersprache, Python, DNS FEHLER, DNS-Server, Python 3

Meistgelesene Beiträge zum Thema Python 3