7

I recently purchased a new laptop, so I'd be able to work not just from my workstation.

I have a Django REST app, and for this project I'm using a VirtualEnv.

My question is:
How can I "sync" the virtualenv to install the new dependencies packages?

In my workstation I installed Django, Django REST, etc...
What can I do so in my laptop I won't have to manually install the new dependencies every-time?

Amir Tugi
  • 2,386
  • 3
  • 16
  • 18
  • I don't think there's an easy way. There are many hard-coded directory paths within the virtualenv, so unless you copy the virtualenv to the exact same directory from old machine to the new one, it's hard to get it to work. But on the other side, if you have `requirements.txt` ready, it's almost trivial to install everything from it. – Shang Wang Dec 10 '15 at 19:46

1 Answers1

8

Activate your virtual environment, then run:

pip freeze > requirements.txt

However you are transferring the code, you can transfer this file. Then on your laptop, can you make it part of your sync script:

pip install -r requirements.txt

Typically I have a pair of sh files that looks like

# upload change
pip freeze > requirements.txt
git add -a .
git commit -m "message"
git push

And

# Get files
git pull
pip install -r requirements.txt
triunenature
  • 651
  • 2
  • 7
  • 23