我在我的 Raspbian Linux 上默认安装了 Python 3.2,但我想要 Python 3.4(time.perf_counter、yield from 等)。通过 apt-get 安装 Python 3.4 没问题,但是当我在我的 shell 中键入 python3 时,我仍然得到 Python 3.2(因为 /usr/bin/python3 仍然链接到它)。我应该更改符号链接(symbolic link),还是这样做更好?
请您参考如下方法:
您不得更改符号链接(symbolic link),因为可能有一些 Debian 实用程序脚本依赖于 python3 是 Python 3.2 或安装了特定的库。有许多命令行实用程序依赖于 Debian 和派生版本的特定版本;例如,在我的 Ubuntu 上,/usr/bin 中有脚本,shebang 上有 python3; python3 表示 操作系统保持当前状态的 Python 3。如果您手动安装 Python 3,它并不是操作系统认为可用作所有脚本的 python3。来 self 的 Ubuntu 14.10 系统的示例:
[/usr/bin]% python3 bluez-list-devices
[/usr/bin]% python3.4 bluez-list-devices
[/usr/bin]% python3.3 bluez-list-devices
Traceback (most recent call last):
File "bluez-list-devices", line 3, in <module>
import dbus
File "/usr/lib/python3/dist-packages/dbus/__init__.py", line 82, in <module>
import dbus.types as types
File "/usr/lib/python3/dist-packages/dbus/types.py", line 6, in <module>
from _dbus_bindings import (
ImportError: No module named '_dbus_bindings'
[/usr/bin]% head -n 1 bluez-list-devices
#!/usr/bin/python3
如果您自行决定更改符号链接(symbolic link),最坏的情况是您会使系统无法启动。
直接使用python3.4作为命令,或者使用虚拟环境。
