删除错误“usr / lib / python2.7”,如何解决?

时间:2014-08-24 07:05:32

标签: python pythonpath

在编辑Django应用程序期间,我删除了" usr / lib / python2.7"中的python2.7文件夹。错误的。

发生这个问题后,我总是在使用时得到msg如下:

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是Ubuntu12.04 ----

我试图参考这些页面:

  

http://bugs.python.org/issue6060

     

Python/IPython ImportError: no module named site

并尝试使用

sudo apt-get install --reinstall重新安装python2.7.8版本

我的PYTHONPATH现在看起来像

  

PYTHONDIR = usr / local / lib / python2.7,

     

PYTHONHOME = usr / local / lib / python2.7,

     

PYTHONPATH =

但我仍然得到&#34; ImportError:没有名为site&#34的模块; MSG

如果我尝试输入

Import sys

我会得到msg&#34; import:无法打开图像`sys&#39;:@ error / blob.c / OpenBlob / 2587。&#34;

我想知道现在我的问题是什么,以及如何解决它?

非常感谢,

1 个答案:

答案 0 :(得分:2)

首先,要小心 - 甚至是限制性的 - 关于你以root身份运行的东西。普通用户无法修改/ usr / lib下的内容,并且有充分的理由 - 它会破坏系统。

其次,您可以使用以下命令找出该目录中包含的内容:

$ 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

(是的,列表很长。)知道该列表,我们可以请求重新安装这些包:

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

我为很长的命令行道歉;这里的sed命令清除dpkg的输出,只生成我们要重新安装的包列表。这种方法很可能有助于你提到的具体问题,但即使它出现一次也表明你不清楚其他变化的结果。您可能希望放慢速度并了解有关系统结构的更多信息。

PYTHON*变量之类的东西对你没有多大帮助,除非你在其他地方有一个精确匹配的Python版本,我们在Linux发行版上往往会避免这种情况,因为我们通常有工作(尽管有限)的包管理。

最后,我认为这个问题最终会超出堆栈溢出的超级用户问题。