ubuntu - Python uninstall woes -


i setting first python package described here , seemed necessary python 2.7.13 finish. not realizing how integral python 2.7.12 ubuntu's health, moved 2.7.12 dirs (/usr/local/lib/python2.7/) backup dirs , replaced them 2.7.13 dirs , removed python3. led series of problems killed desktop (no launcher, no alt-t terminal) after lengthy battle required me alt-f1 non-gui terminal, undo directory swaps, , detailed here after

sudo apt-get install --reinstall python2.7 sudo apt-get install python3-all 

and

sudo apt-get install ubuntu-desktop 

things normal except can't reinstall pip (to use ipython amongst others) due lacking ctypes. i'm willing reinstall ubuntu if have to.

jeremy@jr:~$ python  python 2.7.12 (default, nov 19 2016, 06:48:10)  [gcc 5.4.0 20160609] on linux2 type "help", "copyright", "credits" or "license" more information. >>> import ctypes traceback (most recent call last):   file "<stdin>", line 1, in <module>   file "/usr/local/lib/python2.7/ctypes/__init__.py", line 7, in <module>     _ctypes import union, structure, array importerror: no module named _ctypes 

the current state of affairs far know how check:

jeremy@jr:~$ echo $pythonhome /usr/local/lib/python2.7:/usr/local/lib/python2.7.12 jeremy@jr:~$ echo $pythonpath /usr/local/lib/python2.7:/usr/local/lib/python2.7.12:/usr/local/lib/python2.7/site-packages:/home/jeremy/sw/caffe/python:/home/jeremy/sw/models/slim:/home/jeremy/sw/models:/home/jeremy/sw/models/utils: jeremy@jr:~$ python  /usr/bin/python jeremy@jr:~$ ls -l /usr/bin/python* lrwxrwxrwx 1 root root      16 aug 17 23:37 /usr/bin/python -> /usr/bin/python2 lrwxrwxrwx 1 root root       9 dec 10  2015 /usr/bin/python2 -> python2.7 -rwxr-xr-x 1 root root 3546104 nov 19  2016 /usr/bin/python2.7 lrwxrwxrwx 1 root root      33 nov 19  2016 /usr/bin/python2.7-config -> x86_64-linux-gnu-python2.7-config lrwxrwxrwx 1 root root      16 dec 10  2015 /usr/bin/python2-config -> python2.7-config lrwxrwxrwx 1 root root       9 mar 23  2016 /usr/bin/python3 -> python3.5 -rwxr-xr-x 2 root root 4460336 nov 17  2016 /usr/bin/python3.5 -rwxr-xr-x 2 root root 4460336 nov 17  2016 /usr/bin/python3.5m lrwxrwxrwx 1 root root      10 mar 23  2016 /usr/bin/python3m -> python3.5m lrwxrwxrwx 1 root root      16 dec 10  2015 /usr/bin/python-config -> python2.7-config 

/usr/local/lib/python2.7 looks ok, bunch of scripts _abcoll.py zipfile.pyc.

pip broken , giving error

jeremy@jr:/usr/src/python-2.7.12$ pip install ctypes traceback (most recent call last):   file "/usr/local/bin/pip", line 5, in <module>     pkg_resources import load_entry_point importerror: no module named pkg_resources 

which

jeremy@jr:/usr/src/python-2.7.12$ sudo apt-get install --reinstall python-pkg-resources 

does not fix (same error above occurs after reinstall)

the question is, how fix apparently somewhat-broken python install, fix ctypes, pip, , other potentially-missing parts?

jeremy@jr:~$ ls /usr/local/lib/python2.7/ctypes/ _endian.py  _endian.pyc  __init__.py  __init__.pyc  macholib  test  util.py  util.pyc  wintypes.py  wintypes.pyc 

you've reinstalled 1 of packages have things in /usr/lib/python, not of them. ctypes in particular in libpython2.7-stdlib. can ask package manager there , reinstall (scary combination ahead):

sudo apt-get install --reinstall `dpkg -s /usr/lib/python2.7 | sed -e 's%: /usr/lib/python2.7%%' -e 's%, % %g'` 

in general, don't go modifying system directories /usr without package manager's assistance. messes system's idea of what's there or not. there paths own installations, /opt , /usr/local. in case appears you're lucky apt still works.

also, find rather unlikely needed 2.7.13 on 2.7.12; more portion, such python-setuptools or python2.7-dev. ubuntu inherits rather fine grained split of python system debian.

it possible apt pin particular packages alternate sources. instance, possible have hybrid of ubuntu xenial python packages zesty 2.7.13.


Comments

Popular posts from this blog

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -