- 您使用系统软件包管理器
apt-get
安装了该软件包,但尝试与本地anaconda环境一起使用。那是行不通的:与系统软件包管理器一起安装的软件包应与系统安装的python一起使用。要将软件包安装到虚拟环境(包括anaconda)中,请使用conda
或pip
。我正在尝试从Debian 10中的Python3导入tkSnack。
我已经从apt安装了tkSnack:
apt-get install python3-tksnack
无论如何,当尝试从python3导入tkSnack模块时:
ModuleNotFoundError: No module named 'tkSnack'
我也尝试从pip安装tkSnack,但出现以下错误消息:
ERROR: Command errored out with exit status 1: command: /home/cooper/anaconda3/bin/python -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-x8rnbcp1/snack/setup.py'"'"'; __file__='"'"'/tmp/pip-install-x8rnbcp1/snack/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /tmp/pip-install-x8rnbcp1/snack/pip-egg-info cwd: /tmp/pip-install-x8rnbcp1/snack/ Complete output (6 lines): Traceback (most recent call last): File "<string>", line 1, in <module> File "/tmp/pip-install-x8rnbcp1/snack/setup.py", line 47 print GCC_VERSION ^ SyntaxError: Missing parentheses in call to 'print'. Did you mean print(GCC_VERSION)? ---------------------------------------- ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
很奇怪,当在python2.7中导入tkSnack时,一切正常!
有人对此有任何想法吗?解冻!
<<apt-get
安装了该软件包,但尝试与本地anaconda环境一起使用。那是行不通的:与系统软件包管理器一起安装的软件包应与系统安装的python一起使用。要将软件包安装到虚拟环境(包括anaconda)中,请使用conda
或pip
。SyntaxError
中的print
表示该代码仅适用于Python2;在Python3中,print
成为一个函数,并且需要括号:print(GCC_VERSION)
。看来您安装了错误的,仅Python2版本的软件包,并试图将其与Python3一起使用。卸载并重新安装Python3的代码更新。