首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >当我尝试执行apt-get install python3 3-pexpect时出现dpkg错误。

当我尝试执行apt-get install python3 3-pexpect时出现dpkg错误。
EN

Ask Ubuntu用户
提问于 2017-09-23 12:06:07
回答 1查看 1.4K关注 0票数 0
代码语言:javascript
复制
:~$ sudo apt-get install python3-pexpect
Reading package lists... Done
Building dependency tree       
Reading state information... Done
python3-pexpect is already the newest version.
The following packages were automatically installed and are no longer required:
  freeglut3-dev libglew-dev libgoogle-perftools4 libtcmalloc-minimal4
  libunwind8 libv8-3.14.5 mongodb mongodb-clients mongodb-dev mongodb-server
  python-bson python-bson-ext python-gridfs python-pyassimp python-pymongo
  python-pymongo-ext ros-indigo-household-objects-database-msgs
  ros-indigo-ompl ros-indigo-pr2-arm-kinematics ros-indigo-pr2-moveit-plugins
  ros-indigo-warehouse-ros texmaker-data
Use 'apt-get autoremove' to remove them.
The following extra packages will be installed:
  python-libxml2 python-samba
The following packages will be upgraded:
  python-libxml2 python-samba
2 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
6 not fully installed or removed.
Need to get 0 B/1.207 kB of archives.
After this operation, 1.024 B of additional disk space will be used.
Do you want to continue? [Y/n] y
(Reading database ... 844116 files and directories currently installed.)
Preparing to unpack .../python-libxml2_2.9.1+dfsg1-3ubuntu4.10_amd64.deb ...
  File "/usr/bin/pyclean", line 63
    except (IOError, OSError), e:
                             ^
SyntaxError: invalid syntax
dpkg: warning: subprocess old pre-removal script returned error exit status 1
dpkg: trying script from the new package instead ...
  File "/usr/bin/pyclean", line 63
    except (IOError, OSError), e:
                             ^
SyntaxError: invalid syntax
dpkg: error processing archive /var/cache/apt/archives/python-libxml2_2.9.1+dfsg1-3ubuntu4.10_amd64.deb (--unpack):
 subprocess new pre-removal script returned error exit status 1
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 while cleaning up:
 subprocess installed post-installation script returned error exit status 1
Preparing to unpack .../python-samba_2%3a4.3.11+dfsg-0ubuntu0.14.04.12_amd64.deb ...
  File "/usr/bin/pyclean", line 63
    except (IOError, OSError), e:
                             ^
SyntaxError: invalid syntax
dpkg: warning: subprocess old pre-removal script returned error exit status 1
dpkg: trying script from the new package instead ...
  File "/usr/bin/pyclean", line 63
    except (IOError, OSError), e:
                             ^
SyntaxError: invalid syntax
dpkg: error processing archive /var/cache/apt/archives/python-samba_2%3a4.3.11+dfsg-0ubuntu0.14.04.12_amd64.deb (--unpack):
 subprocess new pre-removal script returned error exit status 1
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 while cleaning up:
 subprocess installed post-installation script returned error exit status 1
Errors were encountered while processing:
 /var/cache/apt/archives/python-libxml2_2.9.1+dfsg1-3ubuntu4.10_amd64.deb
 /var/cache/apt/archives/python-samba_2%3a4.3.11+dfsg-ubuntu0.14.04.12_amd64.deb

E: Sub-process /usr/bin/dpkg returned an error code (1)
EN

回答 1

Ask Ubuntu用户

发布于 2017-12-06 13:56:25

这是由于错误:

代码语言:javascript
复制
File "/usr/bin/pyclean", line 63
    except (IOError, OSError), e:

很可能是因为它期望python2.x而不是python3。

您必须将/usr/bin/python链接到适当的版本。如果我没有弄错,/usr/bin/python --version会输出3.x,所以您可能需要创建一个指向python2.x的符号链接:

代码语言:javascript
复制
ls -la /usr/bin/python  # you will see if there's a symlink towards some other file
rm /usr/bin/python      # only if it is a symlink!
ln -s /usr/bin/python2.x /usr/bin/python 

其中2.x是您版本的python。

或者,更简单地说,但是您需要同时安装2.x和3.x:

代码语言:javascript
复制
sudo update-alternatives --config python
票数 1
EN
页面原文内容由Ask Ubuntu提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://askubuntu.com/questions/958679

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档