Implicit Module Search in Python?
I'm working on a more complete understanding of Python Virtual Environment for portablity issues across cheap hosting solutions and development platforms and there are pieces I don't understand.
I've been building virtual environments, but I'm not seeing the COMPLETE ISOLATION I need for copying virtual environments to hosts assuming the hosts don't have python installed
The problem is I'll build a platform P that's not completely isolated from the system P -- bin/python2.6 -- lib/python2.6/site-packages
PATH is changed to contain only P/bin/
PYTHONPATH is blank
Works perfect. But, it still visits system directories to resolve what's not in the virtual environment. WHY??
in this case P =/tmp/pinax2/ `
import sys
print sys.path
['', '/tmp/pinax2/lib/python2.6/site-packages/setuptools-0.6c11-py2.6.egg', '/tmp/pinax2/lib/python2.6/site-packages/pip-0.8.1-py2.6.egg', '/home/marc/PythonPersonalWorkspace/mcapps/societysource', '/tmp/pinax2/lib/python2.6', '/tmp/pinax2/lib/python2.6/plat-linux2', '/tmp/pinax2/lib/python2.6/lib-tk', '/tmp/pinax2/lib/python2.6/lib-old', '/tmp/pinax2/lib/python2.6/lib-dynload', '/usr/lib/python2.6', '/usr/lib/python2.6/plat-linux2', '/usr/lib/python2.6/lib-tk', '/tmp/pinax2/lib/python2.6/site-packages', '/usr/local/lib/python2.6/dist-packages/pydelicious-0.6-py2.6.egg', '/usr/local/lib/python2.6/dist-packages/feedparser-4.1-py2.6.egg', '/usr/local/lib/python2.6/dist-packages/nose-0.11.3-py2.6.egg', '/usr/local/lib/python2.6/dist-packages/decorator-3.2.0-py2.6.egg', '/usr/local/lib/python2.6/dist-packages/FormEncode-1.2.2-py2.6.egg', '/usr/local/lib/python2.6/dist-packages/PasteScript-1.7.3-py2.6.egg', '/usr/local/lib/python2.6/dist-packages/PasteDeploy-1.3.3-py2.6.egg', '/usr/local/li b/python2.6/dist-packages/Beaker-1.5.4-py2.6.egg', '/usr/local/lib/python2.6/dist-packages/Routes-1.12.3-py2.6.egg', '/usr/local/lib/python2.6/dist-packages/docutils-0.4-py2.6.egg', '/usr/local/lib/python2.6/dist-packages/simplejson-2.0.9-py2.6.egg', '/usr/local/lib/python2.6/dist-packages/WebHelpers-0.6.4-py2.6.egg', '/usr/local/lib/python2.6/dist-packages/Mako-0.3.6-py2.6.egg', '/usr/local/lib/python2.6/dist-packages/MarkupSafe-0.11-py2.6.egg', '/usr/local/lib/python2.6/dist-packages/Tempita-0.4-py2.6.egg', '/usr/local/lib/python2.6/dist-packages/WebTest-1.2-py2.6.egg', '/usr/local/lib/python2.6/dist-packages/WebError-0.10.2-py2.6.egg', '/usr/local/lib/python2.6/dist-packages/Pygments-1.3.1-py2.6.egg', '/usr/local/lib/python2.6/dist-packages/AuthKit-0.4.5-py2.6.egg', '/usr/local/lib/python2.6/dist-packages/elementtree-1.2.7_20070827_preview-py2.6.egg', '/usr/local/lib/python2.6/dist-packages/distribute-0.6.14-py2.6.egg', '/usr/local/lib/python2.6/dist-packages/setuptools-0.6c11-py2.5 .egg', '/usr/local/lib/python2.6/dist-packages/Myghty-1.2-py2.6.egg', '/usr/local/lib/python2.6/dist-packages/recaptcha_client-1.0.5-py2.6.egg', '/usr/local/lib/python2.6/dist-packages/pyfacebook-1.0a2-py2.6.egg', '/usr/local/lib/python2.6/dist-packages/BeautifulSoup-3.2.0-py2.6.egg', '/usr/local/lib/python2.6/dist-packages/flup-1.0.3.dev_20100525-py2.6.egg', '/usr/local/lib/python2.6/dist-packages/JCC-1.9-py2.6-linux-i686.egg', '/usr/local/lib/python2.6/dist-packages/mechanize-0.2.4-py2.6.egg', '/usr/local/lib/python2.6/dist-packages/Pylons-1.0-py2.6.egg', '/usr/local/lib/python2.6/dist-packages/pyparsing-1.5.5-py2.6.egg', '/usr/local/lib/python2.6/dist-packages/python_dateutil-1.5-py2.6.egg', '/usr/local/lib/python2.6/dist-packages/z3ext.lucene-1.1.4-py2.6.egg', '/usr/local/lib/python2.6/dist-packages/zope.app.catalog-3.8.1-py2.6.egg', '/usr/local/lib/python2.6/dist-packages/zope.app.container-3.9.1-py2.6.egg', '/usr/local/lib/python2.6/dist-packages/zope.app.pagetemplate-3.11.2-py2. 6.egg', '/usr/local/lib/python2.6/dist-packages/zope.app.appsetup-3.15.0-py2.6.egg', '/usr/local/lib/python2.6/dist-packages/zope.app.intid-3.7.1-py2.6.egg', '/usr/local/lib/python2.6/dist-packages/zope.app.twisted-3.5.0-py2.6.egg', '/usr/local/lib/python2.6/dist-packages/zope.i18nmessageid-3.5.3-py2.6-linux-i686.egg', '/usr/local/lib/python2.6/dist-packages/zope.index-3.6.1-py2.6-linux-i686.egg', '/usr/local/lib/python2.6/dist-packages/zope.proxy-3.6.1-py2.6-linux-i686.egg', '/usr/local/lib/python2.6/dist-packages/zope.schema-3.7.1-py2.6.egg', '/usr/local/lib/python2.6/dist-packages/zope.publisher-3.12.6-py2.6.egg', '/usr/local/lib/python2.6/dist-packages/zope.component-3.10.0-py2.6.egg', '/usr/local/lib/python2.6/dist-packages/zope.catalog-3.8.1-py2.6.egg', '/usr/local/lib/python2.6/dist-packages/zope.app.publisher-3.10.2-py2.6.egg', '/usr/local/lib/python2.6/dist-packages/zope.traversing-3.13.1-py2.6.egg', '/usr/local/lib/python2.6/dist-packages/zope.size-3.4.1-py2.6.egg', '/usr/loc al/lib/python2.6/dist-packages/zope.security-3.8.0-py2.6-linux-i686.egg', '/usr/local/lib/python2.6/dist-packages/zope.location-3.9.0-py2.6.egg', '/usr/local/lib/python2.6/dist-packages/zope.lifecycleevent-3.6.2-py2.6.egg', '/usr/local/lib/python2.6/dist-packages/zope.i18n-3.7.4-py2.6.egg', '/usr/local/lib/python2.6/dist-packages/zope.exceptions-3.6.1-py2.6.egg', '/usr/local/lib/python2.6/dist-packages/zope.event-3.5.0_1-py2.6.egg', '/usr/local/lib/python2.6/dist-packages/zope.dublincore-3.8.1-py2.6.egg', '/usr/local/lib/python2.6/dist-packages/zope.copypastemove-3.8.0-py2.6.egg', '/usr/local/lib/python2.6/dist-packages/zope.container-3.12.0-py2.6-linux-i686.egg', '/usr/local/lib/python2.6/dist-packages/zope.browser-1.3-py2.6.egg', '/usr/local/lib/python2.6/dist-packages/zope.tales-3.5.1-py2.6.egg', '/usr/local/lib/python2.6/dist-packages/zope.pagetemplate-3.5.2-py2.6.egg', '/usr/local/lib/python2.6/dist-packages/zope.configuration-3.7.2-py2.6.egg', '/usr/local/lib/python2.6/dist-packa ges/zope.browserpage-3.12.2-py2.6.egg', '/usr/local/lib/python2.6/dist-packages/zope.site-3.9.2-py2.6.egg', '/usr/local/lib/python2.6/dist-packages/zope.session-3.9.3-py2.6.egg', '/usr/local/lib/python2.6/dist-packages/zope.processlifetime-1.0-py2.6.egg', '/usr/local/lib/python2.6/dist-packages/zope.error-3.7.2-py2.6.egg', '/usr/local/lib/python2.6/dist-packages/zope.app.publication-3.12.0-py2.6.egg', '/usr/local/lib/python2.6/dist-packages/ZODB3-3.10.1-py2.6-linux-i686.egg', '/usr/local/lib/python2.6/dist-packages/zope.intid-3.7.2-py2.6.egg', '/usr/local/lib/python2.6/dist-packages/zope.app.server-3.5.0-py2.6.egg', '/usr/local/lib/python2.6/dist-packages/zope.app.wsgi-3.10.0-py2.6.egg', '/usr/local/lib/python2.6/dist-packages/zope.app.applicationcontrol-3.5.9-py2.6.egg', '/usr/local/lib/python2.6/dist-packages/zdaemon-2.0.4-py2.6.egg', '/usr/local/lib/python2.6/dist-packages/ZConfig-2.8.0-py2.6.egg', '/usr/local/lib/python2.6/dist-packages/zope.contenttype-3.5.1-py2.6.egg', '/usr/loca l/lib/python2.6/dist-packages/zope.annotation-3.5.0-py2.6.egg', '/usr/local/lib/python2.6/dist-packages/zope.componentvocabulary-1.0.1-py2.6.egg', '/usr/local/lib/python2.6/dist-packages/zope.ptresource-3.9.0-py2.6.egg', '/usr/local/lib/python2.6/dist-packages/zope.datetime-3.4.0-py2.6.egg', '/usr/local/lib/python2.6/dist-packages/zope.browserresource-3.12.0-py2.6.egg', '/usr/local/lib/python2.6/dist-packages/zope.browsermenu-3.9.1-py2.6.egg', '/usr/local/lib/python2.6/dist-packages/pytz-2010o-py2.6.egg', '/usr/local/lib/python2.6/dist-packages/zope.copy-3.5.0-py2.6.egg', '/usr/local/lib/python2.6/dist-packages/zope.broken-3.6.0-py2.6.egg', '/usr/local/lib/python2.6/dist-packages/zope.filerepresentation-3.6.0-py2.6.egg', '/usr/local/lib/python2.6/dist-packages/zope.dottedname-3.4.6-py2.6.egg', '/usr/local/lib/python2.6/dist-packages/zope.tal-3.5.2-py2.6.egg', '/usr/local/lib/python2.6/dist-packages/RestrictedPython-3.6.0-py2.6.egg', '/usr/local/lib/python2.6/dist-packages/zope.hookable -3.4.1-py2.6-linux-i686.egg', '/usr/local/lib/python2.6/dist-packages/zope.minmax-1.1.2-py2.6.egg', '/usr/local/lib/python2.6/dist-packages/zope.authentication-3.7.1-py2.6.egg', '/usr/local/lib/python2.6/dist-packages/zc.lockfile-1.0.0-py2.6.egg', '/usr/local/lib/python2.6/dist-packages/transaction-1.1.1-py2.6.egg', '/usr/local/lib/python2.6/dist-packages/zope.keyreference-3.6.2-py2.6.egg', '/usr/local/lib/python2.6/dist-packages/zope.password-3.6.1-py2.6.egg', '/usr/local/lib/python2.6/dist-packages/zope.server-3.8.2-py2.6.egg', '/usr/local/lib/python2.6/dist-packages/zope.testing-3.10.2-py2.6.egg', '/usr/local/lib/python2.6/dist-packages/zope.testbrowser-3.10.3-py2.6.egg', '/usr/local/lib/python2.6/dist-packages/wsgi_intercept-0.4-py2.6.egg', '/usr/local/lib/python2.6/dist-packages/zope.applicationcontrol-3.5.5-py2.6.egg', '/usr/local/lib/python2.6/dist-packages/Paste-1.7.3.1-py2.6.egg', '/usr/local/lib/python2.6/dist-packages/SQLAlchemy-0.6.6-py2.6.egg', '/usr/local/lib/python2.6/di st-packages/virtualenv-1.5.1-py2.6.egg', '/usr/local/lib/python2.6/dist-packages/Reindent-0.1.1-py2.6.egg', '/usr/local/lib/python2.6/dist-packages/roman-1.4.0-py2.6.egg', '/usr/local/lib/python2.6/dist-packages/WebOb-1.0.1-py2.6.egg', '/usr/local/lib/python2.6/dist-packages/weakrefset-1.0.0-py2.6.egg', '/usr/local/lib/python2.6/dist-packages/django_openid-0.1.5-py2.6.egg', '/usr/lib/pymodules/python2.6', '/usr/local/lib/python2.6/dist-packages/django_extensions-0.6-py2.6.egg', '/usr/local/lib/python2.6/dist-packages/django_robots-0.8.0-py2.6.egg', '/usr/local/lib/python2.6/dist-packages/django_friends-0.1.5-py2.6.egg', '/usr/local/lib/python2.6/dist-packages/django_mailer-0.1.0-py2.6.egg', '/usr/local/lib/python2.6/dist-packages/django_messages-0.4.4-py2.6.egg', '/usr/local/lib/python2.6/dist-packages/django_announcements-0.1.2-py2.6.egg', '/usr/local/lib/python2.6/dist-packages/django_oembed-0.1.3-py2.6.egg', '/usr/local/lib/python2.6/dist-packages/django_db_log-2.2.1-py2.6.egg', '/u sr/local/lib/python2.6/dist-packages/django_pagination-1.0.7-py2.6.egg', '/usr/local/lib/python2.6/dist-packages/django_threadedcomments-0.5.3-py2.6.egg', '/usr/local/lib/python2.6/dist-packages/django_bookmarks-0.1.0-py2.6.egg', '/usr/local/lib/python2.6/dist-packages/django_ajax_validation-0.1.3-py2.6.egg', '/usr/local/lib/python2.6/dist-packages/django_photologue-2.3-py2.6.egg', '/usr/local/lib/python2.6/dist-packages/django_avatar-1.0.5-py2.6.egg', '/usr/local/lib/python2.6/dist-packages/django_flag-0.1.1-py2.6.egg', '/usr/local/lib/python2.6/dist-packages/django_microblogging-0.1.2-py2.6.egg', '/usr/local/lib/python2.6/dist-packages/django_locations-0.1.1-py2.6.egg', '/usr/local/lib/python2.6/dist-packages/django_uni_form-0.7.0-py2.6.egg', '/usr/local/lib/python2.6/dist-packages/django_sorting-0.1-py2.6.egg', '/usr/local/lib/python2.6/dist-packages/django_markup-0.3-py2.6.egg', '/usr/local/lib/python2.6/dist-packages/django_staticfiles-0.3.4-py2.6.egg', '/usr/local/lib/python2.6/d ist-packages/django_email_confirmation-0.1.4-py2.6.egg', '/usr/local/lib/python2.6/site-packages', '/usr/local/lib/python2.6/dist-packages', '/usr/lib/python2.6/dist-packages', '/usr/lib/python2.6/dist-packages/PIL', '/usr/lib/python2.6/dist-packages/gst-0.10', '/usr/lib/python2.6/dist-packages/gtk-2.0', '/usr/lib/pymodules/python2.6/gtk-2.0']
`
Are you talking about virtualenv? There's an option when you create the virtual environment that excludes all existing site packages. I think that's what you want.
virtualenv --no-site-packages env
链接地址: http://www.djcxy.com/p/23340.html
上一篇: 任何想法,为什么我得到这个错误?
下一篇: Python中的隐式模块搜索?