How to check whether virtualenv was created with '--no-site-packages'?

前端 未结 3 1755
半阙折子戏
半阙折子戏 2020-12-31 04:29

Sometimes I get errors that I suspect are the result of my Django app using globally installed Python modules/Django apps instead of those within its virtualenv.

Is

3条回答
  •  一整个雨季
    2020-12-31 04:54

    There's a file in /lib/pythonX.X/ called no-global-site-packages.txt when you create a virtual environment with --no-site-packages.

    Just tried this with virtualenv 1.7:

    % virtualenv --no-site-packages env.without
    % virtualenv --system-site-packages env.with
    
    % find env.without | sed 's/env.without//' > files.without
    % find env.with | sed 's/env.with//' > files.with
    
    % diff files.with*
    230a231
    > /lib/python3.2/no-global-site-packages.txt
    

提交回复
热议问题