The simplest solution would be to pipe the result of pip freeze
to grep
with -v
(invert-match):
pip freeze | grep -v 'project_name' > requirements.txt
Demo:
$ mkvirtualenv test
New python executable in test/bin/python
Installing Setuptools...done.
Installing Pip...done.
(test)$ pip freeze
wsgiref==0.1.2
(test)$ pip install requests
Downloading/unpacking requests
Downloading requests-2.2.1.tar.gz (421kB): 421kB downloaded
Running setup.py egg_info for package requests
Installing collected packages: requests
Running setup.py install for requests
Successfully installed requests
Cleaning up...
(test)$ pip freeze
requests==2.2.1
wsgiref==0.1.2
(test)$ pip freeze | grep -v 'requests'
wsgiref==0.1.2
(test)$ pip freeze | grep -v 'requests' > requirements.txt
(test)$ cat requirements.txt
wsgiref==0.1.2
Also see: Negative matching using grep (match lines that do not contain foo).
Hope that helps.