1

While working on a new python project and trying to learn my way through virtual environments, I've stumbled twice with the following problem:

  • I create my virtual environment called venv. Running pip freeze shows nothing.
  • I install my dependencies using pip install dependency. the venv library starts to populate, as confirmed by pip freeze.
  • After a couple of days, I go back to my project, and after activating the virtual environment via source venv/bin/activate, when running pip freeze I see the whole list of libraries installed in the system python distribution (I'm using Mac Os 10.9.5), instead of the small subset I wanted to keep inside my virtual environment.

I'm sure I must be doing something wrong in between, but I have no idea how could this happen. Any ideas?


Update: after looking at this answer, I realized the that when running pip freeze, the pip command that's being invoked is the one at /usr/local/bin/pip instead of the one inside my virtual environment. So the virtual environment is fine, but I wonder what changes in the path might be causing this, and how to prevent them to happen again (my PYTHONPATH variable is not set).

Community
  • 1
  • 1
jimijazz
  • 2,197
  • 1
  • 15
  • 24

1 Answers1

0

I realized that my problem arose when moving my virtual environment folder around the system. The fix was to modify the activate and pip scripts located inside the venv/bin folder to point to the new venv location, as suggested by this answer. Now my pip freeze is showing the right files.

Community
  • 1
  • 1
jimijazz
  • 2,197
  • 1
  • 15
  • 24