0
:~$ 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)

1 Answer 1

1

It's due to the error:

File "/usr/bin/pyclean", line 63
    except (IOError, OSError), e:

Most probably it is because it's expecting python2.x instead of python3.

You must link /usr/bin/python to the appropriate version. If I'm not mistaken /usr/bin/python --version will output 3.x So maybe you need to create a symlink to python2.x:

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 

where 2.x is your version of python.

Or, more simply, but you need to have both 2.x and 3.x installed:

sudo update-alternatives --config python

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .