2016-04-02 27 views
1

每當我嘗試使用apt-get install安裝包時,我會遇到以下錯誤:無法獲取安裝包E:子進程/ usr/bin/dpkg返回錯誤代碼(1)

After this operation, 0 B of additional disk space will be used. 
Do you want to continue? [Y/n] y 
Setting up python-support (1.0.15) ... 
    File "/usr/sbin/update-python-modules", line 52 
    print x 
     ^
SyntaxError: Missing parentheses in call to 'print' 
dpkg: error processing package python-support (--configure): 
subprocess installed post-installation script returned error exit status 1 
Setting up mercurial-common (3.1.2-2+deb8u1) ... 
Traceback (most recent call last): 
    File "/usr/bin/pycompile", line 35, in <module> 
    from debpython.version import SUPPORTED, debsorted, vrepr, \ 
    File "/usr/share/python/debpython/version.py", line 24, in <module> 
    from ConfigParser import SafeConfigParser 
ImportError: No module named 'ConfigParser' 
dpkg: error processing package mercurial-common (--configure): 
subprocess installed post-installation script returned error exit status 1 
dpkg: dependency problems prevent configuration of mercurial: 
mercurial depends on mercurial-common (= 3.1.2-2+deb8u1); however: 
    Package mercurial-common is not configured yet. 

dpkg: error processing package mercurial (--configure): 
dependency problems - leaving unconfigured 
Errors were encountered while processing: 
python-support 
mercurial-common 
mercurial 
E: Sub-process /usr/bin/dpkg returned an error code (1) 

我目前在我的機器上使用Python 3.4.2。

回答

5

您是否將Python2的默認Python更改爲Python3?目前,Debian帶有一個default Python2 installation。用Python編寫的系統腳本(如/usr/sbin/update-python-modules)期望python運行Python2的一個版本。將默認Python更改爲Python3會導致各種腳本中斷。如果您確實將Python3設爲默認值,那麼解決當前問題的方法是恢復並使Python2再次成爲默認值。


在Python2 print是一個語句,所以print x是有效的。

在Python3中print是一個函數,因此調用函數需要將參數包裝在括號內。所以print x必須改爲print(x)print x提出了一個SyntaxError

File "/usr/sbin/update-python-modules", line 52 
    print x 
     ^
SyntaxError: Missing parentheses in call to 'print' 

除了更改系統默認的蟒蛇,使用pyenv or virtualenv來管理Python的多個版本之間/開關。

+0

此外:不要指望mercurial與python3一起工作,它嚴格要求python2。截至撰寫時,Python3尚不支持將mercurial移植到python3所需的一切。 – planetmaker

相關問題