如果我的问题是新手,我很抱歉,但我觉得这很奇怪。 我有以下代码:
import apt_pkg
import apt
pkg="linux-image-4.4.0-116-generic"
p=apt.progress.text.AcquireProgress()
c=apt.Cache()
u=c[pkg].candidate.uri
a=apt_pkg.Acquire(p)
apt_pkg.AcquireFile(a,uri=u)
a.run()
在iPython上它起作用,在iPython之外它不起作用。
来自iPyhton:
In [3]: pkg="linux-image-4.4.0-116-generic"
In [4]: c=apt.Cache()
u=c[pkg].candidate.uri
In [5]: u=c[pkg].candidate.uri
In [6]: p=apt.progress.text.AcquireProgress()
In [7]: a=apt_pkg.Acquire(p)
In [8]: apt_pkg.AcquireFile(a,uri=u)
Out[8]: <apt_pkg.AcquireFile object:Status: 0 Complete: 0 Local: 0 IsTrusted: 0 FileSize: 0 DestFile:'linux-image-4.4.0-116-generic_4.4.0-116.140_i386.deb' DescURI: 'http://it.archive.ubuntu.com/ubuntu/pool/main/l/linux/linux-image-4.4.0-116-generic_4.4.0-116.140_i386.deb' ID:0 ErrorText: ''>
In [9]: a.run()
Get:1 [20.7 MB]
Fetched 20.7 MB in 6s (1643 kB/s)
Out[9]: 0
来自shell的:
myuser@mypc:~/github/mycode$ ./aptciao.py
Fetched 0 B in 0s (0 B/s)