4

I'm following the tutorial to deploy Django applications on Heroku.

In the 5th line of the code, it says pip freeze > requirements.txt but when I run it (from the venv), the requirements.txt file is empty! It produced 6-7 dependencies with the same code before.

How can I fix this?

Gino Mempin
  • 25,369
  • 29
  • 96
  • 135
jeff
  • 13,055
  • 29
  • 78
  • 136

3 Answers3

4

That probably means the dependencies are installed on your global environment.

Switch to the virtual environment, and install the dependencies manually using pip install <dependency> and then running pip freeze should output the dependencies.

Gino Mempin
  • 25,369
  • 29
  • 96
  • 135
DelGiudice
  • 1,847
  • 1
  • 17
  • 14
  • 1
    I was using venv (activating it too) but I never thought of installing the dependencies myself beforehand. I will try that. Thanks, – jeff Oct 22 '16 at 15:38
  • I faced such an issue after Python 3 upgrade. My old way of doing `pip freeze`was not working anymore (empty list) . I suppose a path issue (surely need to update python (or PIP) path after its upgrade ; I have to document myself because I'm not sure how to do it) but after doing `python3 -m pip freeze > requirements.txt`, I could see again the list of all my dependencies. – Abpostman1 Feb 07 '23 at 10:58
1

This answer is for posterity

  • This could be because of pip being deprecated.So upgrade pip by using
python -m pip install -–upgrade pip

Then run pip freeze > requirements.txt as usually.This should do the job.

0

I get the same error but I figured it out now. I had my virtual environment set up using PowerShell (preferred for sys commands) that has the dependencies installed but I was running the Python shell with the command "pip freeze > requuiremnts.txt". When I ran the same command on PowerShell then I got requirements.txt populated with dependencies.