1

I have a simple project in Pycharm that I am working to load up on a VPS. I would like to utilize pip freeze to build a requirements.txt file and install required packages on the VPS.

Unfortunately, when i activate the venv associated with my project, the output of pip freeze appears to be all of the packages in my default python3 installation, and not my project.

I uploaded a screenshot showing Python Interpreter settings and terminal pip freeze output.

In this case, the venv should only contain pip, selenium, setuptools, urllib3. However, no matter how I try to activate the venv (Pycharm terminal, os x terminal) and deactivate, the output of pip freeze is always the long list of packages that seems to be what I have installed to the normal Python3 environment.

I'm wondering if Pycharm is somehow "overmanaging" my packages or if I;m just going wrong somewhere.

Thank you!

screenshot

learyjk
  • 599
  • 1
  • 5
  • 14
  • 1
    seems like different envs :) open terminal tab in pycharm IDE and type `which python` then compare output with `which python` in your default terminal window (where you've activated venv) – madzohan Nov 28 '20 at 23:03
  • running with no env: which python3 gives /usr/local/bin/python3 – learyjk Nov 28 '20 at 23:37
  • after I cd to the proper directory and activate the venv which python3 yields /Users/keeganleary/PycharmProjects/instagram-bot/venv/bin/python and pip freeze still outputs the long list of packages. – learyjk Nov 28 '20 at 23:38
  • 1
    Does this answer your question? [How to freeze packages installed only in the virtual environment?](https://stackoverflow.com/questions/8073097/how-to-freeze-packages-installed-only-in-the-virtual-environment) – Shivam Miglani Nov 29 '20 at 00:55
  • All it took was the -m flag. pip -m freeze produced the result I was looking for. After a bit of looking I still can't figure out why... – learyjk Nov 29 '20 at 06:41
  • *How* did you activate your environment? It is very tempting to just call the `activate` script like this: `./myenv/bin/activate`. This spawns a new shell context, executes the path settings, etc., and then drops out of this shell again. Instead, you have to interpret the activation in the current shell: `. myapp/bin/activate` or more elaborate `source myapp/bin/activate`. – Nils Magnus Apr 11 '23 at 09:49

1 Answers1

3

Seems my pip was still the global pip such that when I ran which pip I got /usr/local/bin/pip3. By using the venv pip I was able to get the packages for that project only.

path/to/venv/bin/pip3 freeze

also the following worked.

python3 -m pip freeze
learyjk
  • 599
  • 1
  • 5
  • 14