安装特定python版本的python包
据我所知,在Ubuntu 14.04中,您可以访问python 2.7.6和python 3.4.0。 通过命令行获取python包时,如何确保我安装的是用于python 2.7.6的软件包,而不是用于python 3.4.0?
使用apt-file
查找包名称。 例如,如果要安装正确版本的reportlab,请使用:
apt-file -l search reportlab
在我的系统上,这会产生:
gambas3-gb-report python-mvpa2 python-pdfrw python-pisa python-renderpm python-renderpm-dbg python-reportlab python-reportlab-accel python-reportlab-accel-dbg python-reportlab-doc python3-renderpm python3-renderpm-dbg python3-reportlab python3-reportlab-accel python3-reportlab-accel-dbg
可以假设包python-reportlab是2.7版本,包python3-reportlab是python 3.x版本。 但是如果你想进一步检查你可以使用dpkg -L python-reportlab
– 这将列出包内容,你会看到文件在/usr/lib/python2.7
。
不幸的是, dpkg -L
仅适用于已安装的软件包,因此如果要在安装软件包之前检查它,则必须使用Ubuntu软件包Web界面 。 打开包详细信息页面后 ,可以单击文件列表,查看文件是在/usr/lib/python2.7
还是在/usr/lib/python3
。