[Django]-How to locate a virtualenv install

2👍

Create your own virtualenv

If all fails, just recreate the virtualenv from the requirements.txt and go from there

Find out how the old app was being launched

If you insist on finding the old one, IMO the most direct way is to find how is the production Django app being ran. Look for bash scripts that start it, some supervisor entries etc

If you find how it starts, then you can pinpoint the environment it is launched in (e.g. which virtualenv)

Find the virtualenv by searching for common files

Other than that you can use find or locate command to search for files we know to exist in a virtualenv like lib/pythonX.Y/site-packages, bin/activate or bin/python etc

👤bakkal

0👍

Why not start checking what processes are actually running, and with what commandline, using ps auxf or something of the sort. Then you know if its nginx+uwsgi or django-devserver or what, and maybe even see the virtualenv path, if it’s being launched very manually. Then, look at the config file of the server you find.

Alternatively, look around, using netstat -taupen, for example, which processes are listening to which ports. Makes even more sense, if there’s a reverse proxy like nginx or whatever running, and you know that it’s proxying to.

The requirements.txt I’d ignore completely. You’ll get the same, but correct information from the virtualenv once you activate it and run pip freeze. The file’s superfluous at best, and misleading at worst.

Btw, if this old contractor compiled and installed a custom Python, (s)he might not even have used a virtualenv, while still avoiding the system libraries and PYTHONPATH. Unlikely, but possible.

Leave a comment