Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/linux/28.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python控制台输出在Debian 6中被覆盖_Python_Linux_Debian - Fatal编程技术网

Python控制台输出在Debian 6中被覆盖

Python控制台输出在Debian 6中被覆盖,python,linux,debian,Python,Linux,Debian,我用python编写了一个小脚本,它使用Debian6(Python2.6.6)中的apt-get自动安装了一些包,比如wget、git。然后脚本安装pip,然后使用pip,安装请求和phpserialize。以下是运行脚本时获得的输出: root@ffVMdeb64:~# python test.py Reading package lists... Done mkdir: cannot create directory `/usr/local/src/forpip': File exist

我用python编写了一个小脚本,它使用Debian6(Python2.6.6)中的apt-get自动安装了一些包,比如wget、git。然后脚本安装
pip
,然后使用
pip
,安装请求和phpserialize。以下是运行脚本时获得的输出:

root@ffVMdeb64:~# python test.py 
Reading package lists... Done
mkdir: cannot create directory `/usr/local/src/forpip': File exists
Building dependency tree       
Reading state information... Done
git is already the newest version.
wget is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
Reading package lists... Done
Building dependency tree... 50%


Building dependency tree       
Reading state information... Done
Requirement already satisfied (use --upgrade to upgrade): phpserialize in /usr/local/lib/python2.6/dist-packages
Cleaning up...
Requirement already satisfied (use --upgrade to upgrade): requests in /usr/local/lib/python2.6/dist-packages
Cleaning up...
git is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
最后,脚本从用户那里获取一些输入。但是,
raw_input
语句在安装过程的输出仍在进行时执行,因此被覆盖。请注意上面2个输出块之间的空白,也就是<代码> RWYPixEng/Cux>语句被打印然后重写的地方。< /P> 脚本的相关部分如下:

subprocess.call("pip install phpserialize &> /dev/null 2>&1", shell=True)
subprocess.call("pip install requests &> /dev/null  2>&1", shell=True)
subprocess.call("apt-get install git -y &> /dev/null 2>&1", shell=True)
import phpserialize
import requests
from phpserialize import serialize
from phpserialize import unserialize

def checktext():
    text = raw_input("\n\n\nEnter your text:")
    return text

itext = checktext()
我在CentOS 6.3和6.4中测试了完全相同的脚本,它按预期工作。我想这与
构建依赖关系树有关。。。50%
部分
apt get
但我不确定


我该如何纠正这一点?

这可能不是确切的解决方案,我很确定会有更好的解决方案,但我认为如果您在上一次
apt get
语句后尝试
睡眠
,可能会奏效

根据您的代码:

import time
subprocess.call("pip install phpserialize &> /dev/null 2>&1", shell=True)
subprocess.call("pip install requests &> /dev/null  2>&1", shell=True)
subprocess.call("apt-get install git -y &> /dev/null 2>&1", shell=True)
time.sleep(5)
import phpserialize
import requests
from phpserialize import serialize
from phpserialize import unserialize

def checktext():
    text = raw_input("\n\n\nEnter your text:")
    return text

itext = checktext()
这会导致整个
apt get
首先执行,然后转到
text=…
station

希望这有帮助