On Thu, Nov 22, 2012 at 10:19 AM, Luisa Beck <
emmi...@gmail.com> wrote:
> But say I create a virtual environment and install a script that depends on
> another script that I haven't included in the virtual environment. That
> leads me to an error because the script can't be found in that virtual
> environment. Why doesn't the interpreter then look outside of my virtual
> environment?
what does "depends on another script" means? usually it's that
somewhere you have a line like "import otherscript".
try this
python -c 'import sys;print sys.path'
both inside and outside a virtualenv. that's the main thing
virtualenv manages: the list of directories where the intepreter looks
for python code.
i hope that will explain why you get that error. the idea of
virtualenv is that by limiting where the interpreter looks for code
makes it easy to know what are your dependencies. If it was allowed
to look behind your back, you'll soon start depending on code that you
didn't install without realizing it.
the other big part of what virtualenv does is to interact with pip, so
when you say "pip install Django" (or any other python-only package),
it knows to install it within the virtualenv path. (modules that
compile a C extension also work, but not so easily).
finally, this means that you can simply do "pip freeze >
requirements.txt" to get a list of exactly what packages (and the
version of each one) are in your virtualenv, and therefore accessible
to your project. keep the requirements.txt file on the same version
control as the rest of the project, and deployment becomes little more
than:
- create virtualenv on server, activate it
- check out your project
- pip install -r requirements.txt
- ./manage.py syncdb
--
Javier