5

SITUATION:

I have created a python package where I use the following libraries:

  1. matplotlib
  2. regex
  3. statistics
  4. os
  5. unittest
  6. coverage

my problem is that when I do pip freeze, the result only returns versions values for

  1. matplotlib==3.2.1
  2. regex==2020.11.13
  3. statistics==1.0.3.5
  4. coverage==5.3.1

I have read some sites where they say that this is because, for example, os and unittest comes already installed with Python3.X.

QUESTION:

  1. Should I include 'os', 'unittest' in 'requirements.txt'?
  2. If so, which is the version I should write?
idriskameni
  • 173
  • 1
  • 1
  • 6
  • 3
    The source you were reading is right. Os, unittest etc are already installed so you don't have to include them in reqs.txt – Leemosh Jan 10 '21 at 14:20
  • 3
    os and unittest are in the [standard library](https://docs.python.org/3/library/index.html). You didn't install them via pip, so they don't need to be in the requirements file. – jonrsharpe Jan 10 '21 at 14:25

3 Answers3

5

You shouldn't include os and unittest in requirements.txt.

As you read, I confirm that os and unittest are included in Python 3.X.

os and unittest version depends on your Python 3.X version.

2

The source was right, you should't include os etc in your requirements.txt. Here is a little different problem with pip freeze tho - when you are not using different environments and have all the libraries in one environment, your pip freeze is gonna give you all the libraries you have inside and that is not helpful at all.

I'd recommend using pipreqs library for getting all the necessary libraries you want to put in your requirements.txt for your script.

pip install pipreqs

pipreqs /path/to/your_project
Leemosh
  • 883
  • 6
  • 19
-3

python3 -m pip install -r requirements.txt

  • 1
    The question is not *how* to install the file. This is not an answer. – Gert Arnold Jun 12 '22 at 17:34
  • As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Jun 12 '22 at 17:47