Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to freeze packages installed only in the virtual environment?

How to freeze packages installed only in the virtual environment, that is, without the global ones?

like image 706
saul.shanabrook Avatar asked Nov 09 '11 23:11

saul.shanabrook


People also ask

How do I freeze pip without version?

All you need is to install pip-chill from PyPI and run pip-chill from your Python environment. If you are feeling adventurous and don't want to pin versions (or want to use pip-compile), you can use pip-chill --no-version and it'll give you the minimal requirements for your current environment.

What is pip freeze command?

pip freeze shows packages YOU installed via pip (or pipenv if using that tool) command in a requirements format. Remark below that setuptools, pip, wheel are installed when pipenv shell creates my virtual envelope.


5 Answers

You need to use the -l or --local option to freeze only the local packages (and not the global ones)

pip freeze -l > requirements.txt 

Make sure you are working in the virtualenv before doing pip freeze -l.

like image 99
Muneeb Ali Avatar answered Oct 02 '22 19:10

Muneeb Ali


Only local packages on virtual environment

pip freeze -l > requirements.txt # or --local instead of -l

Only local packages installed by the user on virtual environment

pip freeze --user > requirements.txt

See the documentation for further details: https://pip.pypa.io/en/stable/reference/pip_freeze/.

like image 31
Bitcoin Mexico Avatar answered Oct 02 '22 19:10

Bitcoin Mexico


For me (macOS) the following worked

path/to/venv/bin/pip3 freeze -l
like image 42
Codey Avatar answered Oct 02 '22 20:10

Codey


I'm on Windows 10, python 3.6, with my virtual environment called env activated using command prompt I found that pip freeze -l does not work (error), python -m pip freeze -l does not work (gets global packages) but changing into my virtual environment Scripts directory and running pip freeze or pip freeze -l works. Here is an example of this solution/work-around with my virtual environment, env:

cd \env\Scripts
pip freeze > ..\..\requirements.txt
like image 40
orangecaterpillar Avatar answered Oct 02 '22 20:10

orangecaterpillar


python venv/Path_to/bin/pip freeze -l 
like image 44
Agustin Maria Pardo Avatar answered Oct 02 '22 19:10

Agustin Maria Pardo



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!