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?
2
  • 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 Commented Jan 10, 2021 at 14:20
  • 3
    os and unittest are in the standard library. You didn't install them via pip, so they don't need to be in the requirements file. Commented Jan 10, 2021 at 14:25

3 Answers 3

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.

Sign up to request clarification or add additional context in comments.

Comments

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

1 Comment

Note: pipreqs doesn't support Python 3.6+
-3

python3 -m pip install -r requirements.txt

2 Comments

The question is not how to install the file. This is not an answer.
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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.