我是 Linux 新手,正在尝试在我的计算机上设置 Python/Django!我从源文件安装了 Python 3.3,并将其编译为。然后我在和/usr/local/bin
之间创建了一个符号链接,这样每当我从命令行调用 python 时,它都会使用最新版本。/usr/bin/python
/usr/local/bin/python3
现在我尝试安装 MySQL Python 并得到以下输出:
apt-get install python-mysqldb
Reading package lists... Done
Building dependency tree
Reading state information... Done
python-mysqldb is already the newest version.
The following extra packages will be installed:
apt-listchanges python-apt
Suggested packages:
python-glade2 python-gtk2 python-apt-dbg python-vte python-apt-doc
The following packages will be upgraded:
apt-listchanges python-apt
2 upgraded, 0 newly installed, 0 to remove and 142 not upgraded.
3 not fully installed or removed.
Need to get 0 B/394 kB of archives.
After this operation, 250 kB of additional disk space will be used.
Do you want to continue [Y/n]? Y
Traceback (most recent call last):
File "/usr/bin/apt-listchanges", line 28, in <module>
import apt_pkg
ImportError: No module named 'apt_pkg'
有什么办法可以解决这个问题吗?或者有什么关于如何清理此安装的提示(如果这个安装太破损的话)?
答案1
Debian 中太多软件包仍然依赖 Python 2.x。因此,几乎每个人都需要安装 Python 2.x。
通常,需要执行以下操作才能同时拥有 Python 2.x 和 3.x:
/usr/bin/python
指的是 Python 2.x 二进制文件/usr/bin/python3
指的是 Python 3.x 二进制文件
要查看计算机上当前安装的 Python 版本,请运行:
ls -l /usr/bin/python*
(结果例如/usr/bin/python2.7
)
要删除符号链接:rm -i /usr/bin/python
要创建符号链接:ln -s /usr/bin/python2.7 /usr/bin/python