ImportError: cannot import name 'urlencode' in Python3 beheben
English
Deutsch
Problem:
Dein Python 3.x-Interpreter gibt die Fehlermeldung
importerror.txt
ImportError: cannot import name 'urlencode'Lösung
Wie von Fred Foo hier auf StackOverflow beschrieben, enthält Python3 urlencode() nicht im urllib-Modul, sondern in urllib.parse.
Daher musst du
fix_urlencode.py
from urllib import urlencodeändern in
fix_compat_urlencode.py
from urllib.parse import urlencodeWenn du Code für sowohl Python2 als auch Python3 schreiben möchtest, verwende bevorzugt:
fix_compat_tryexcept.py
try:
from urllib import urlencode
except ImportError:
from urllib.parse import urlencodeCheck out similar posts by category:
Python
If this post helped you, please consider buying me a coffee or donating via PayPal to support research & publishing of new posts on TechOverflow