Die Conda-Umgebung ist Python = 3.8 und das Tap-Modul wird im Code verwendet.
from tap import Tap
Frage 1
Python2- und Python3-Syntaxkonflikt
File "/home/cedric/anaconda3/envs/decision_diffuser_env/lib/python3.8/site-packages/tap.py", line 6, in <module>
from mc_bin_client import mc_bin_client, memcacheConstants as Constants
File "/home/cedric/anaconda3/envs/decision_diffuser_env/lib/python3.8/site-packages/mc_bin_client/mc_bin_client.py", line 278
except MemcachedError, e:
^
SyntaxError: invalid syntax
Lösung
Ändern Sie die Datei mc_bin_client.py, Zeilen 278, 369, 396
Ändern:
except MemcachedError as e:
Frage 2
Das Ausnahmemodul in Python2 wird in Python3 nicht mehr unterstützt
File "/home/cedric/anaconda3/envs/decision_diffuser_env/lib/python3.8/site-packages/tap.py", line 6, in <module>
from mc_bin_client import mc_bin_client, memcacheConstants as Constants
File "/home/cedric/anaconda3/envs/decision_diffuser_env/lib/python3.8/site-packages/mc_bin_client/mc_bin_client.py", line 11, in <module>
import exceptions
ModuleNotFoundError: No module named 'exceptions'
Lösung
- Kommentieren Sie die Importausnahme aus. Python3 muss sie nicht importieren und erbt die Ausnahme direkt.
- Zeile 24, wechseln zu
class MemcachedError(Exception):
Frage 3
So importieren Sie MemcacheConstants
from memcacheConstants import REQ_MAGIC_BYTE, RES_MAGIC_BYTE
from memcacheConstants import REQ_PKT_FMT, RES_PKT_FMT, MIN_RECV_PACKET
from memcacheConstants import SET_PKT_FMT, INCRDECR_RES_FMT
import memcacheConstants
Lösung
Ändern
from .memcacheConstants import REQ_MAGIC_BYTE, RES_MAGIC_BYTE
from .memcacheConstants import REQ_PKT_FMT, RES_PKT_FMT, MIN_RECV_PACKET
from .memcacheConstants import SET_PKT_FMT, INCRDECR_RES_FMT
from . import memcacheConstants