Reputation: 9
During editting the Django apps, I deleted the python2.7 folder in "usr/lib/python2.7" by mistake.
After that problem happened, I always got the msg as following when using :
Could not find platform independent libraries <prefix> Could not find platform dependent libraries <exec_prefix> Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>] ImportError: No module named site
--- os is Ubuntu12.04 ----
I have tried to refer to these pages:
and also try to use
sudo apt-get install --reinstall
to reinstall the python2.7.8 version
My PYTHONPATH now looks like
PYTHONDIR= usr/local/lib/python2.7,
PYTHONHOME= usr/local/lib/python2.7,
PYTHONPATH=
but I still get "ImportError: No module named site" msg
If I try to type
Import sys
I would get the msg "import: unable to open image `sys': @ error/blob.c/OpenBlob/2587."
Many thanks,
Upvotes: 0
Views: 3783
Reputation: 15887
First, be careful - even restrictive - about what you ever run as root. A normal user could not modify things under /usr/lib, and for good reason - it breaks the system.
Second, you can find out what packages contain things in that directory using:
$ dpkg -S /usr/lib/python2.7
python-qgis, python-gdal, python-psycopg2, python-pyspatialite, youtube-dl, virtualbox, duplicity, bzr-git, bzr-builddeb, debconf, ipython, libpython2.7-minimal:i386, libpython2.7-dev:i386, tahoe-lafs, seascope, samba, qbzr, python2.7, python-zope.interface, python-zfec, python-yaml, python-xdg, python-xapian, python-wxversion, python-wxgtk2.8, python-ws4py, python-webob, python-wadllib, python-vipscc, python-utidylib, python-usb, python-urllib3, python-tz, python-twisted, python-twisted-words, python-twisted-web, python-twisted-runner, python-twisted-news, python-twisted-names, python-twisted-mail, python-twisted-lore, python-twisted-core, python-twisted-conch, python-twisted-bin, python-tk, python-tdb, python-talloc, python-support, python-subversion, python-sphinx, python-software-properties, python-six, python-sip, python-simplejson, python-simplegeneric, python-setuptools, python-setools, python-serial, python-sepolicy, python-sepolgen, python-semanage, python-selinux, python-secretstorage, python-scipy, python-samba, python-routes, python-roman, python-requests, python-repoze.lru, python-reportlab, python-reportlab-accel, python-renderpm, python-radare2, python-qt4, python-qt4-gl, python-qscintilla2, python-pyvorbis, python-pytools, python-pysqlite2, python-pyside.qtxml, python-pyside.qtwebkit, python-pyside.qtuitools, python-pyside.qttest, python-pyside.qtsvg, python-pyside.qtsql, python-pyside.qtscript, python-pyside.qtopengl, python-pyside.qtnetwork, python-pyside.qthelp, python-pyside.qtgui, python-pyside.qtdeclarative, python-pyside.qtcore, python-pyside.phonon, python-pyparsing, python-pyopencl, python-pygments, python-pygame, python-pycurl, python-pycryptopp, python-pyaudio, python-pyasn1, python-poppler-qt4, python-ply, python-pkg-resources, python-pivy, python-pip, python-pil, python-pexpect, python-paramiko, python-pam, python-openssl, python-opengl, python-opencv, python-ogg, python-oauthlib, python-oauth, python-numpy, python-ntdb, python-newt, python-nevow, python-networkx, python-netifaces, python-mysqldb, python-musicbrainz, python-mock, python-mechanize, python-markupsafe, python-markdown, python-mako, python-magic, python-lxml, python-libxml2, python-ldb, python-lazr.uri, python-lazr.restfulclient, python-launchpadlib, python-keyring, python-jinja2, python-ipy, python-imaging, python-httplib2, python-html5lib, python-gtk2, python-gst0.10, python-gst0.10-rtsp, python-gpgme, python-gobject-2, python-glade2, python-gi, python-freenect, python-foolscap, python-feedparser, python-fastimport, python-eyed3, python-enchant, python-egenix-mxtools, python-egenix-mxdatetime, python-ecdsa, python-dulwich, python-docutils, python-docopt, python-dnspython, python-distro-info, python-distlib, python-decorator, python-debian, python-dbus, python-dateutil, python-cssutils, python-cssselect, python-crypto, python-configobj, python-colorama, python-collada, python-cherrypy3, python-chardet, python-bzrlib, python-bluez, python-beautifulsoup, python-audit, python-apt, python-apsw, policycoreutils, mercurial, mercurial-common, lsb-release, iotop, hugin-tools, hplip, frescobaldi, libpython2.7:i386, libpython2.7-stdlib:i386, dblatex, cython, cfv, bzr-upload, bzr-search, bzr-pipeline, bzr-loom, bzr-explorer: /usr/lib/python2.7
(Yes, the list is very long.) Knowing that list, we can request those packages to be reinstalled:
$ sudo apt-get install --reinstall `dpkg -S /usr/lib/python2.7 | sed -e s/,//g -e 's/: .*$//'`
I apologise for the very long command line; the sed
command here cleans up the output of dpkg to produce only the list of packages we want to reinstall. This method is likely to help with the specific issue you mention, but even having it occur once suggests you're not clear on the consqeuences of other changes. You may want to slow down and learn more about your system's structure.
Things like PYTHON*
variables won't help you much unless you have a precisely matching version of Python elsewhere, something we tend to avoid on Linux distributions because we usually have working (albeit limited) package management.
Lastly, I think the question ends up more of a superuser question than stack overflow.
Upvotes: 3