Python中的隐式模块搜索?
我正在更全面地了解Python虚拟环境,以了解廉价托管解决方案和开发平台中的可移植性问题,并且有些内容我不明白。
我一直在构建虚拟环境,但我没有看到完整的隔离,我需要将虚拟环境复制到主机,假设主机没有安装python
问题是,我将建立,这不是完全从装置P隔离的平台P -斌/ python2.6的- LIB / python2.6的/站点包
PATH更改为仅包含P / bin /
PYTHONPATH是空白的
完美的作品。 但是,它仍然访问系统目录来解决不在虚拟环境中的内容。 为什么??
在这种情况下P = / tmp / pinax2 /`
进口系统
打印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-包/ 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-包/ 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']
`
你在说virtualenv吗? 创建排除所有现有网站包的虚拟环境时有一个选项。 我认为这就是你想要的。
virtualenv --no-site-packages env
链接地址: http://www.djcxy.com/p/23339.html
上一篇: Implicit Module Search in Python?
下一篇: virtualenv confusion